Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb.net to c#.net

Status
Not open for further replies.

cathiec

Programmer
Oct 21, 2003
139
0
0
IE
hi!

does anyone know how to convert the following code to c# from vb:

Dim sid() As Byte
sid = DirectCast(groupSid, Byte())
'groupSid is an object

thanks

 
Byte sid;
sid = Convert.ChangeType(groupSid, Type.GetType("Byte"));
 
RhymesWithOrange is correct, although I don't usually like using that many brackets... Confuses my little mind ;)

Code:
byte[] sid;
sid = (byte[])groupSid;

Type-casting can be done without the additional brackets, unless of course you're trying to expose properties of the type-casted object (or go through the array) in which case you would need the brackets:

Code:
byte[] sid;
sid = ((byte[])groupSid)[0]; // This will access the 0th element of the byte array

... And there was my totally unneeded explanation for the day ;)

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
thanks eveyone!
ryhmeswithoranges solution seems to work best for my program, thanks again!
 
Yeah, I've noticed that with Instant C# on a couple of things with extra brackets...

I guess it's to play it safe.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top