0

In c# i could do it like:

send.Write((ushort)9);

"send" is an instance of BinaryWriter, how can i do it in vb.net ? I've tried it like:

send.Write((UShort)9)

but i get "UShort is a type and cannot be used as an expression"

Thanks!

2 Answers2

2

This will work on all versions of VB.NET:

send.Write(CType(9, System.UInt16))
Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
1

A closer translation would be:

send.Write(ctype(9, UShort))
Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • send.Write((CUShort(9))) Think i will do it this way, still thank you both! –  Aug 01 '09 at 15:03