Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
Questionmanually running class library in cmd Pin
sasire188-Mar-06 0:27
sasire188-Mar-06 0:27 
AnswerRe: manually running class library in cmd Pin
Steve Hansen8-Mar-06 0:52
Steve Hansen8-Mar-06 0:52 
QuestionConvert struct to byte[] Pin
Divyang Mithaiwala8-Mar-06 0:26
Divyang Mithaiwala8-Mar-06 0:26 
AnswerRe: Convert struct to byte[] Pin
Le centriste8-Mar-06 1:06
Le centriste8-Mar-06 1:06 
GeneralRe: Convert struct to byte[] Pin
Divyang Mithaiwala8-Mar-06 1:35
Divyang Mithaiwala8-Mar-06 1:35 
GeneralRe: Convert struct to byte[] Pin
Le centriste8-Mar-06 3:25
Le centriste8-Mar-06 3:25 
GeneralRe: Convert struct to byte[] Pin
Divyang Mithaiwala8-Mar-06 3:34
Divyang Mithaiwala8-Mar-06 3:34 
AnswerRe: Convert struct to byte[] Pin
Andy Moore8-Mar-06 4:06
Andy Moore8-Mar-06 4:06 
Here's how.

public struct MyStruct
{
   public int x;
   public int y;
   public float z;
}

IntPtr p;
MyStruct s;
int size;
byte[] buffer;

s = new MyStruct();

s.x = 1;
s.y = 2;
s.z = 3.0f;

size = sizeof( typeof( MyStruct ) );

p = Marshal.AllocHGlobal( size );

Marshal.PtrToStructure( s, p, true );
buffer = new byte[ size ];

Marshal.Copy( p, buffer, 0, size );

Marshal.FreeHGlobal( p );


I hope this helps.

Deus caritas est
GeneralRe: Convert struct to byte[] Pin
Andy Moore8-Mar-06 4:11
Andy Moore8-Mar-06 4:11 
GeneralRe: Convert struct to byte[] Pin
Divyang Mithaiwala8-Mar-06 17:25
Divyang Mithaiwala8-Mar-06 17:25 
AnswerRe: Convert struct to byte[] Pin
mcljava12-Mar-06 15:34
mcljava12-Mar-06 15:34 
Questionaccessing remote registry Pin
sendmadhavan8-Mar-06 0:21
sendmadhavan8-Mar-06 0:21 
AnswerRe: accessing remote registry Pin
Le centriste8-Mar-06 1:07
Le centriste8-Mar-06 1:07 
GeneralRe: accessing remote registry Pin
sendmadhavan8-Mar-06 1:58
sendmadhavan8-Mar-06 1:58 
GeneralRe: accessing remote registry Pin
Le centriste8-Mar-06 2:01
Le centriste8-Mar-06 2:01 
GeneralRe: accessing remote registry Pin
sendmadhavan8-Mar-06 2:08
sendmadhavan8-Mar-06 2:08 
GeneralRe: accessing remote registry Pin
Le centriste8-Mar-06 2:10
Le centriste8-Mar-06 2:10 
GeneralRe: accessing remote registry Pin
sendmadhavan8-Mar-06 2:13
sendmadhavan8-Mar-06 2:13 
Questiondisable button functions Pin
Dave McCool7-Mar-06 23:31
Dave McCool7-Mar-06 23:31 
AnswerRe: disable button functions Pin
gnjunge7-Mar-06 23:47
gnjunge7-Mar-06 23:47 
GeneralRe: disable button functions Pin
Dave McCool8-Mar-06 0:39
Dave McCool8-Mar-06 0:39 
QuestionStart Button panel context menu Pin
Dave McCool7-Mar-06 23:29
Dave McCool7-Mar-06 23:29 
Questiontreeview windowsform control in csharp Pin
eng.islam7-Mar-06 23:23
eng.islam7-Mar-06 23:23 
AnswerRe: treeview windowsform control in csharp Pin
Chandana Subasinghe8-Mar-06 0:27
Chandana Subasinghe8-Mar-06 0:27 
Questionplaying movie Pin
Mihai si atat7-Mar-06 23:22
Mihai si atat7-Mar-06 23:22 

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.