Click here to Skip to main content
15,888,579 members
Home / Discussions / C#
   

C#

 
GeneralRe: Staticlly Link Assemblys Pin
Nick Parker4-Aug-04 5:02
protectorNick Parker4-Aug-04 5:02 
GeneralPassng TextBox Object.... Pin
Anonymous3-Aug-04 18:22
Anonymous3-Aug-04 18:22 
GeneralRe: Passng TextBox Object.... Pin
Jay Shankar3-Aug-04 18:44
Jay Shankar3-Aug-04 18:44 
GeneralRe: Passng TextBox Object.... Pin
Korjiro3-Aug-04 19:41
Korjiro3-Aug-04 19:41 
GeneralRe: Passng TextBox Object.... Pin
Jay Shankar3-Aug-04 19:52
Jay Shankar3-Aug-04 19:52 
GeneralRe: Passng TextBox Object.... Pin
exhaulted3-Aug-04 22:51
exhaulted3-Aug-04 22:51 
GeneralVS 2003 Designer bug? -- Duplicate declaration error Pin
ddelapasse3-Aug-04 16:04
ddelapasse3-Aug-04 16:04 
General"sizeof" in C# Pin
crushinghellhammer3-Aug-04 12:55
crushinghellhammer3-Aug-04 12:55 
I need to translate the following C++ code to C#

for (int i = 0; i < sizeof(mnX)/sizeof(float); i++)
{
mnX[i] = 0f;
}

where (in C#)

float[] mnX = new float[2];

Using this line as it is in C# results in a compile error which says that "sizeof" can be used only in an unsafe context.

I changed the line to the following:

for( int i = 0; i < System.Runtime.InteropServices.Marshal.SizeOf(mnX)/sizeof(float); i++ )
{ mnX[i] = 0f; }

which, of course, still results in the same error.

My question is this: when I tried to use
System.Runtime.InteropServices.Marshal.SizeOf(float), that resulted in a compile error as well.

I don't want to wrap this block of code with the *unsafe* keyword and then compile using /unsafe.

What would be my best option?

Thanks!

// Added 4:00PM PDT

I guess I could just replace sizeof(float) with 4. Still, just for the sake of knowing how, I'd like to know how to get around the problem. Wink | ;)
GeneralRe: &quot;sizeof&quot; in C# Pin
Member 11737603-Aug-04 13:31
Member 11737603-Aug-04 13:31 
GeneralRe: &quot;sizeof&quot; in C# Pin
NietzscheDisciple3-Aug-04 13:35
NietzscheDisciple3-Aug-04 13:35 
GeneralFilling a combo box from a database Pin
Jefferys3-Aug-04 12:25
Jefferys3-Aug-04 12:25 
GeneralRe: Filling a combo box from a database Pin
DougW483-Aug-04 12:38
DougW483-Aug-04 12:38 
GeneralListcontrol text alignment. Pin
Christian Graus3-Aug-04 12:22
protectorChristian Graus3-Aug-04 12:22 
GeneralRe: Listcontrol text alignment. Pin
Member 11737603-Aug-04 16:18
Member 11737603-Aug-04 16:18 
GeneralRe: Listcontrol text alignment. Pin
Christian Graus3-Aug-04 16:22
protectorChristian Graus3-Aug-04 16:22 
GeneralRe: Listcontrol text alignment. Pin
Member 11737603-Aug-04 16:37
Member 11737603-Aug-04 16:37 
GeneralRe: Listcontrol text alignment. Pin
Christian Graus3-Aug-04 16:44
protectorChristian Graus3-Aug-04 16:44 
GeneralRe: Listcontrol text alignment. Pin
Member 11737603-Aug-04 17:06
Member 11737603-Aug-04 17:06 
GeneralRe: Listcontrol text alignment. Pin
Christian Graus3-Aug-04 17:09
protectorChristian Graus3-Aug-04 17:09 
GeneralRe: Revenue Counter Pin
Colin Angus Mackay3-Aug-04 12:00
Colin Angus Mackay3-Aug-04 12:00 
GeneralRe: Revenue Counter Pin
RadioButton3-Aug-04 12:13
RadioButton3-Aug-04 12:13 
Generalbeginning a c# database Pin
Miles Roberts3-Aug-04 11:12
Miles Roberts3-Aug-04 11:12 
GeneralRe: beginning a c# database Pin
Nick Parker3-Aug-04 11:27
protectorNick Parker3-Aug-04 11:27 
GeneralRe: beginning a c# database Pin
Colin Angus Mackay3-Aug-04 11:48
Colin Angus Mackay3-Aug-04 11:48 
GeneralRe: beginning a c# database Pin
Miles Roberts3-Aug-04 11:53
Miles Roberts3-Aug-04 11:53 

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.