Click here to Skip to main content
15,896,402 members
Home / Discussions / C#
   

C#

 
QuestionSQL Connection DialogBox Pin
ScottM18-Jun-07 2:07
ScottM18-Jun-07 2:07 
QuestionPacking a class into a byte array - would [Serializable] do the trick? Pin
Dewald8-Jun-07 2:02
Dewald8-Jun-07 2:02 
AnswerRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
AikinX8-Jun-07 2:16
AikinX8-Jun-07 2:16 
GeneralRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
Dewald8-Jun-07 2:38
Dewald8-Jun-07 2:38 
GeneralRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
AikinX8-Jun-07 3:27
AikinX8-Jun-07 3:27 
GeneralRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
Dewald8-Jun-07 3:37
Dewald8-Jun-07 3:37 
GeneralRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
AikinX8-Jun-07 4:08
AikinX8-Jun-07 4:08 
AnswerRe: Packing a class into a byte array - would [Serializable] do the trick? [modified] Pin
AikinX8-Jun-07 20:43
AikinX8-Jun-07 20:43 
Dewald, last night I got an idea: in unmanaged C++ we just need to look at the object as byte array:
<br />
// Some & and * have to be added to next code to say we are working with references<br />
MyClass myCl = new MyClass();<br />
byte[] array = meCl; // this operation is allowed fo references<br />
// coping this array to new one or sending it as is through TCP socet<br />

But in .Net we haven't references (that is very good, in my opinion), but we have some classes that allow to work with objects by references way.
One of them is System.Runtime.InteropServices.Marshal

I have never worked with, just herad about it.
I have being looking through this and find some pairs of static methods wich can help you (I guess):
To get IntPTR from your object:
public static extern void StructureToPtr(object structure, IntPtr ptr, bool fDeleteOld);
public static object PtrToStructure(IntPtr ptr, Type structureType)

To copy to byte array:
public static void Copy(IntPtr source, byte[] destination, int startIndex, int length);
public static void Copy(byte[] source, int startIndex, IntPtr destination, int length)
Or
public static extern byte ReadByte(object ptr, int ofs);
public static extern void WriteByte(IntPtr ptr, int ofs, byte val);

Regards.

P.S. IntPtr (intPointer) is Net analog of C++ pointers


-- modified at 2:48 Saturday 9th June, 2007
GeneralRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
AikinX8-Jun-07 23:50
AikinX8-Jun-07 23:50 
GeneralRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
Dewald10-Jun-07 23:09
Dewald10-Jun-07 23:09 
GeneralRe: Packing a class into a byte array - would [Serializable] do the trick? Pin
AikinX11-Jun-07 0:15
AikinX11-Jun-07 0:15 
QuestionNmericUpDown - set the Value outside the range. HELP!!! Pin
julgri8-Jun-07 1:40
julgri8-Jun-07 1:40 
AnswerRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
Guffa8-Jun-07 1:46
Guffa8-Jun-07 1:46 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
julgri8-Jun-07 6:42
julgri8-Jun-07 6:42 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
Dave Kreskowiak8-Jun-07 6:47
mveDave Kreskowiak8-Jun-07 6:47 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
julgri8-Jun-07 6:56
julgri8-Jun-07 6:56 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
Dave Kreskowiak8-Jun-07 10:08
mveDave Kreskowiak8-Jun-07 10:08 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
julgri8-Jun-07 6:49
julgri8-Jun-07 6:49 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
Dave Kreskowiak8-Jun-07 6:54
mveDave Kreskowiak8-Jun-07 6:54 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
julgri8-Jun-07 7:03
julgri8-Jun-07 7:03 
GeneralRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
Dave Kreskowiak8-Jun-07 10:07
mveDave Kreskowiak8-Jun-07 10:07 
AnswerRe: NmericUpDown - set the Value outside the range. HELP!!! Pin
AikinX9-Jun-07 0:06
AikinX9-Jun-07 0:06 
QuestionString to Byte Array Conversion Pin
M. J. Jaya Chitra8-Jun-07 1:28
M. J. Jaya Chitra8-Jun-07 1:28 
AnswerRe: String to Byte Array Conversion Pin
kristmun8-Jun-07 1:37
kristmun8-Jun-07 1:37 
AnswerRe: String to Byte Array Conversion Pin
Sathesh Sakthivel8-Jun-07 1:37
Sathesh Sakthivel8-Jun-07 1:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.