6 [__DynamicallyInvokable]
12 [__DynamicallyInvokable]
18 [__DynamicallyInvokable]
30 [__DynamicallyInvokable]
39 [SecuritySafeCritical]
40 [__DynamicallyInvokable]
41 public unsafe
static byte[]
GetBytes(
short value)
43 byte[] array =
new byte[2];
44 byte[] array2 = array;
45 fixed (
byte* ptr = array2)
55 [SecuritySafeCritical]
56 [__DynamicallyInvokable]
57 public unsafe
static byte[]
GetBytes(
int value)
59 byte[] array =
new byte[4];
60 byte[] array2 = array;
61 fixed (
byte* ptr = array2)
71 [SecuritySafeCritical]
72 [__DynamicallyInvokable]
73 public unsafe
static byte[]
GetBytes(
long value)
75 byte[] array =
new byte[8];
76 byte[] array2 = array;
77 fixed (
byte* ptr = array2)
88 [__DynamicallyInvokable]
98 [__DynamicallyInvokable]
107 [CLSCompliant(
false)]
108 [__DynamicallyInvokable]
117 [SecuritySafeCritical]
118 [__DynamicallyInvokable]
127 [SecuritySafeCritical]
128 [__DynamicallyInvokable]
144 [__DynamicallyInvokable]
145 public static char ToChar(
byte[] value,
int startIndex)
149 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
151 if ((uint)startIndex >= value.Length)
153 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
155 if (startIndex > value.Length - 2)
157 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
159 return (
char)
ToInt16(value, startIndex);
172 [SecuritySafeCritical]
173 [__DynamicallyInvokable]
174 public unsafe
static short ToInt16(
byte[] value,
int startIndex)
178 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
180 if ((uint)startIndex >= value.Length)
182 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
184 if (startIndex > value.Length - 2)
186 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
188 fixed (
byte* ptr = &value[startIndex])
190 if (startIndex % 2 == 0)
196 return (
short)(*ptr | (ptr[1] << 8));
198 return (
short)((*ptr << 8) | ptr[1]);
212 [SecuritySafeCritical]
213 [__DynamicallyInvokable]
214 public unsafe
static int ToInt32(
byte[] value,
int startIndex)
218 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
220 if ((uint)startIndex >= value.Length)
222 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
224 if (startIndex > value.Length - 4)
226 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
228 fixed (
byte* ptr = &value[startIndex])
230 if (startIndex % 4 == 0)
236 return *ptr | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
238 return (*ptr << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
252 [SecuritySafeCritical]
253 [__DynamicallyInvokable]
254 public unsafe
static long ToInt64(
byte[] value,
int startIndex)
258 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
260 if ((uint)startIndex >= value.Length)
262 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
264 if (startIndex > value.Length - 8)
266 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
268 fixed (
byte* ptr = &value[startIndex])
270 if (startIndex % 8 == 0)
276 int num = *ptr | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
277 int num2 = ptr[4] | (ptr[5] << 8) | (ptr[6] << 16) | (ptr[7] << 24);
278 return (uint)num | ((long)num2 << 32);
280 int num3 = (*ptr << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
281 int num4 = (ptr[4] << 24) | (ptr[5] << 16) | (ptr[6] << 8) | ptr[7];
282 return (uint)num4 | ((long)num3 << 32);
296 [CLSCompliant(
false)]
297 [__DynamicallyInvokable]
298 public static ushort
ToUInt16(
byte[] value,
int startIndex)
302 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
304 if ((uint)startIndex >= value.Length)
306 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
308 if (startIndex > value.Length - 2)
310 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
312 return (ushort)
ToInt16(value, startIndex);
325 [CLSCompliant(
false)]
326 [__DynamicallyInvokable]
327 public static uint
ToUInt32(
byte[] value,
int startIndex)
331 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
333 if ((uint)startIndex >= value.Length)
335 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
337 if (startIndex > value.Length - 4)
339 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
341 return (uint)
ToInt32(value, startIndex);
354 [CLSCompliant(
false)]
355 [__DynamicallyInvokable]
356 public static ulong
ToUInt64(
byte[] value,
int startIndex)
360 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
362 if ((uint)startIndex >= value.Length)
364 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
366 if (startIndex > value.Length - 8)
368 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
370 return (ulong)
ToInt64(value, startIndex);
383 [SecuritySafeCritical]
384 [__DynamicallyInvokable]
385 public unsafe
static float ToSingle(
byte[] value,
int startIndex)
389 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
391 if ((uint)startIndex >= value.Length)
393 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
395 if (startIndex > value.Length - 4)
397 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
399 int num =
ToInt32(value, startIndex);
400 return *(
float*)(&num);
413 [SecuritySafeCritical]
414 [__DynamicallyInvokable]
415 public unsafe
static double ToDouble(
byte[] value,
int startIndex)
419 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value);
421 if ((uint)startIndex >= value.Length)
423 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
425 if (startIndex > value.Length - 8)
427 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
429 long num =
ToInt64(value, startIndex);
430 return *(
double*)(&num);
433 private static char GetHexValue(
int i)
437 return (
char)(i + 48);
439 return (
char)(i - 10 + 65);
453 [__DynamicallyInvokable]
454 public static string ToString(
byte[] value,
int startIndex,
int length)
460 if (startIndex < 0 || (startIndex >= value.Length && startIndex > 0))
468 if (startIndex > value.Length - length)
476 if (length > 715827882)
480 int num = length * 3;
481 char[] array =
new char[num];
483 int num3 = startIndex;
484 for (num2 = 0; num2 < num; num2 += 3)
486 byte b = value[num3++];
487 array[num2] = GetHexValue((
int)b / 16);
488 array[num2 + 1] = GetHexValue((
int)b % 16);
489 array[num2 + 2] =
'-';
491 return new string(array, 0, array.Length - 1);
499 [__DynamicallyInvokable]
506 return ToString(value, 0, value.Length);
517 [__DynamicallyInvokable]
518 public static string ToString(
byte[] value,
int startIndex)
524 return ToString(value, startIndex, value.Length - startIndex);
536 [__DynamicallyInvokable]
537 public static bool ToBoolean(
byte[] value,
int startIndex)
547 if (startIndex > value.Length - 1)
551 if (value[startIndex] != 0)
561 [SecuritySafeCritical]
562 [__DynamicallyInvokable]
565 return *(
long*)(&value);
571 [SecuritySafeCritical]
572 [__DynamicallyInvokable]
575 return *(
double*)(&value);
static ushort ToUInt16(byte[] value, int startIndex)
Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static char ToChar(byte[] value, int startIndex)
Returns a Unicode character converted from two bytes at a specified position in a byte array.
static unsafe long ToInt64(byte[] value, int startIndex)
Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.
static byte [] GetBytes(char value)
Returns the specified Unicode character value as an array of bytes.
static string ToString(byte[] value)
Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecima...
static unsafe long DoubleToInt64Bits(double value)
Converts the specified double-precision floating point number to a 64-bit signed integer.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
static ulong ToUInt64(byte[] value, int startIndex)
Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.
static byte [] GetBytes(ulong value)
Returns the specified 64-bit unsigned integer value as an array of bytes.
static unsafe byte [] GetBytes(short value)
Returns the specified 16-bit signed integer value as an array of bytes.
static string ToString(byte[] value, int startIndex)
Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadec...
Provides information about, and means to manipulate, the current environment and platform....
static unsafe double ToDouble(byte[] value, int startIndex)
Returns a double-precision floating point number converted from eight bytes at a specified position i...
static unsafe int ToInt32(byte[] value, int startIndex)
Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.
static byte [] GetBytes(ushort value)
Returns the specified 16-bit unsigned integer value as an array of bytes.
static byte [] GetBytes(uint value)
Returns the specified 32-bit unsigned integer value as an array of bytes.
Converts base data types to an array of bytes, and an array of bytes to base data types.
static unsafe byte [] GetBytes(float value)
Returns the specified single-precision floating point value as an array of bytes.
static unsafe short ToInt16(byte[] value, int startIndex)
Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.
static unsafe byte [] GetBytes(int value)
Returns the specified 32-bit signed integer value as an array of bytes.
static unsafe byte [] GetBytes(double value)
Returns the specified double-precision floating point value as an array of bytes.
The exception that is thrown when one of the arguments provided to a method is not valid.
static readonly bool IsLittleEndian
Indicates the byte order ("endianness") in which data is stored in this computer architecture.
static uint ToUInt32(byte[] value, int startIndex)
Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.
static unsafe byte [] GetBytes(long value)
Returns the specified 64-bit signed integer value as an array of bytes.
static unsafe double Int64BitsToDouble(long value)
Converts the specified 64-bit signed integer to a double-precision floating point number.
static unsafe float ToSingle(byte[] value, int startIndex)
Returns a single-precision floating point number converted from four bytes at a specified position in...
static byte [] GetBytes(bool value)
Returns the specified Boolean value as a byte array.
static bool ToBoolean(byte[] value, int startIndex)
Returns a Boolean value converted from the byte at a specified position in a byte array.
static string ToString(byte[] value, int startIndex, int length)
Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadec...