C# help real quick

DreamThrall

Newbie
Joined
Oct 14, 2003
Messages
3,484
Reaction score
0
What would be the C# equivilent of this VB code?:

Dim read(256) As [Char]

Thanks
 
I think it creates an array of characters that's 256 characters long.
 
It is used as a 256-character buffer for reading from a text stream... at least that's what I understand...

[EDIT]

I tried doing this:

char[] read[256];

and visual studio is giving me this error:

"Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifer."

wtf does that mean?

edit again:

I think I got it:

char read = new char[256];
 
this has nothing to do with half-life 2 development, but okay...
 
in c++ you would do
char read[256];
or
char *read = new char[256];
they are not the same, the second is a dynamic array.
 
DreamThrall said:
this has nothing to do with half-life 2 development, but okay...

who said it had to be about hl2 development?

are any of the topics on this forum on hl2 development? I don't think so.
 
hasan said:
in c++ you would do
char read[256];
or
char *read = new char[256];
they are not the same, the second is a dynamic array.

'dynamic array' is probably not the best thing to call it - that implies vector bahaviour, i.e. it's size can change dynamically.

'Dynamically allocated array' is better.

/pointless pendancy

edit: and I think the C# should be

char read[] = new char[256];

note the [] after the read
 
we11er is right though in C# unless you're doing something weird what you really want here is a string. You can get more info on the String class in C# here
 
"who said it had to be about hl2 development?"
me :p
however i'm not too worried right now. things will change when the sdk is released.
 
char[] ar = new char[256]; //C# array allocation
char ar[256]; //C++ array allocation
 
Back
Top