holyone
holyone

Reputation:

VB.net BinaryWriter Problem

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!

Upvotes: 0

Views: 327

Answers (2)

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422212

This will work on all versions of VB.NET:

send.Write(CType(9, System.UInt16))

Upvotes: 2

Rowland Shaw
Rowland Shaw

Reputation: 38128

A closer translation would be:

send.Write(ctype(9, UShort))

Upvotes: 1

Related Questions