CSharp examples for System:Int32
Reads a signed 32 bit integer from an array coming from a device.
using System.Text; using System.Linq; using System.Collections.Generic; using System;//w ww . ja v a2s . co m public class Main{ /// <summary> /// Reads a signed 32 bit integer from an array coming from a device. /// </summary> /// <param name="value">the array containing the int</param> /// <param name="offset">the offset in the array at which the int starts</param> /// <returns>the integer read from the array</returns> public static int Swap32bitFromArray ( this byte[] value, int offset ) { int v = 0; v |= ( (int)value[offset] ) & 0x000000FF; v |= ( ( (int)value[offset + 1] ) & 0x000000FF ) << 8; v |= ( ( (int)value[offset + 2] ) & 0x000000FF ) << 16; v |= ( ( (int)value[offset + 3] ) & 0x000000FF ) << 24; return v; } }