{simple} int SomeNumber to 1 byte array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have int SomeNumber (which is less than 256) which I want to convert to 1 byte array so I might send it over TCP. Can someone help me out with writing this line of code?

TIA,
War Eagle
 
War Eagle,

You can do this:

// Create the byte array.
byte[] pbytByte = new byte[]{(byte) intVariable};

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

War Eagle said:
I have int SomeNumber (which is less than 256) which I want to convert to
1 byte array so I might send it over TCP. Can someone help me out with
writing this line of code?
 
Back
Top