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.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • I got an error: 'byte[]' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'byte[]' could be found (are you missing a using directive or an assembly reference?) Commented Jun 20, 2012 at 3:04
  • @user1166981: Make sure to reference System.Linq in your project. (Which version of the .NET framework are you targeting, by the way?) Commented Jun 20, 2012 at 3:05
  • This approach is very slow: Linq is not optimized for byte block copies. It's much faster to do int[] bytesAsInts = new int[ yourBytes.Length / 2 ]; Buffer.BlockCopy( yourBytes, 0, bytesAsInts, 0, yourBytes.Length );. Commented Aug 3, 2021 at 8:40
  • This is a very misleading answer. Typecasting each item of the byte[] will not properly cast the full 4 bytes of each int. Not sure why it is accepted. Commented Nov 6, 2024 at 17:31