Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

C# to VB .Net 2.0 (<< operator cant be used with chrs in vb)

the following line works fine in C#...

public const int LocalHeaderSignature = 'P' | ('K' << 8) | (3 << 16) | (4 << 24);

when I converted it to vb .net, it doesn't allow me to use "<<" with chars

Public Const LocalHeaderSignature As Integer = "P"c Or ("K"c << 8) Or (3 << 16) Or (4 << 24)

what can I do in this case to convert it to vb?

Please help me.

Thanks
Javfarary
[494 byte] By [Javfarary] at [2007-11-11 10:04:52]
# 1 Re: C# to VB .Net 2.0 (<< operator cant be used with chrs in vb)
I'm actually a little suprised that C# allows that.
In VB, you can use the Asc function on the characters and it should work.
David Anton at 2007-11-11 20:48:34 >
# 2 Re: C# to VB .Net 2.0 (<< operator cant be used with chrs in vb)
Instant VB now handles this correctly:
Public Const LocalHeaderSignature As Integer = AscW("P"c) Or (AscW("K"c) << 8) Or (3 << 16) Or (4 << 24)
David Anton at 2007-11-11 20:49:34 >
# 3 Re: C# to VB .Net 2.0 (<< operator cant be used with chrs in vb)
Thanks for the help.

Javfarary
Javfarary at 2007-11-11 20:50:39 >