Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: sizeof() with c#


Message #1 by gary@e... on Wed, 10 Apr 2002 04:22:07
Hi,
  I am trying to use sizeof() in c# to get an array size but get errors 
whatever way I try. Here is the specific code:
	string [] strLong = new string[5];
	strLong[0] = "name1isLong";
	strLong[1] = "name2isLong";
	strLong[2] = "name3isLong";
	strLong[3] = "name4isLong";
	strLong[4] = "name5isLong";

	int intShort = sizeof (strShort);
	int intLong = sizeof (strLong);

Please advise, Thanks.

Message #2 by "Farhan Zia" <farhan-zia@c...> on Wed, 10 Apr 2002 10:20:00 +0500
have you checked what is the return type of the method sizeof()?

----- Original Message -----
From: <gary@e...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Wednesday, April 10, 2002 4:22 AM
Subject: [aspx_beginners] sizeof() with c#


> Hi,
>   I am trying to use sizeof() in c# to get an array size but get errors
> whatever way I try. Here is the specific code:
> string [] strLong = new string[5];
> strLong[0] = "name1isLong";
> strLong[1] = "name2isLong";
> strLong[2] = "name3isLong";
> strLong[3] = "name4isLong";
> strLong[4] = "name5isLong";
>
> int intShort = sizeof (strShort);
> int intLong = sizeof (strLong);
>
> Please advise, Thanks.
>

Message #3 by "Peter" <petemail@r...> on Wed, 10 Apr 2002 01:11:28 -0400
use Length instead:

int[] myary = new int[5] {1,2,3,4,5};
int mylength = myary.Length;

-----Original Message-----
From: gary@e... [mailto:gary@e...]
Sent: Wednesday, April 10, 2002 4:22 AM
To: aspx_beginners
Subject: [aspx_beginners] sizeof() with c#


Hi,
  I am trying to use sizeof() in c# to get an array size but get errors
whatever way I try. Here is the specific code:
	string [] strLong = new string[5];
	strLong[0] = "name1isLong";
	strLong[1] = "name2isLong";
	strLong[2] = "name3isLong";
	strLong[3] = "name4isLong";
	strLong[4] = "name5isLong";

	int intShort = sizeof (strShort);
	int intLong = sizeof (strLong);

Please advise, Thanks.



  Return to Index