{simple} int SomeNumber to 1 byte array

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
 
N

Nicholas Paldino [.NET/C# MVP]

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top