Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 217 characters in body
Source Link
vcsjones
  • 142.2k
  • 34
  • 301
  • 295

Simple:

//Where yourBytes is an initialized byte array. int[] bytesAsInts = yourBytes.Select(x => (int)x).ToArray(); 

Make sure you include System.Linq with a using declaration:

using System.Linq; 

And if LINQ isn't your thing, you can use this instead:

int[] bytesAsInts = Array.ConvertAll(yourBytes, c => (int)c); 

Simple:

//Where yourBytes is an initialized byte array. int[] bytesAsInts = yourBytes.Select(x => (int)x).ToArray(); 

Simple:

//Where yourBytes is an initialized byte array. int[] bytesAsInts = yourBytes.Select(x => (int)x).ToArray(); 

Make sure you include System.Linq with a using declaration:

using System.Linq; 

And if LINQ isn't your thing, you can use this instead:

int[] bytesAsInts = Array.ConvertAll(yourBytes, c => (int)c); 
Source Link
vcsjones
  • 142.2k
  • 34
  • 301
  • 295

Simple:

//Where yourBytes is an initialized byte array. int[] bytesAsInts = yourBytes.Select(x => (int)x).ToArray();