Files
Dec2017-Script-Dump/mscorlib/System/BitConverter.cs
T
2026-06-04 11:42:34 +02:00

599 lines
28 KiB
C#

using System;
using System.Text;
namespace System
{
/// <summary>Converts base data types to an array of bytes, and an array of bytes to base data types.</summary>
/// <filterpriority>2</filterpriority>
// Token: 0x02000641 RID: 1601
public static class BitConverter
{
// Token: 0x06003B44 RID: 15172 RVA: 0x000C9F94 File Offset: 0x000C8194
private static bool AmILittleEndian()
{
double num = 1.0;
return num == (double)0;
}
// Token: 0x06003B45 RID: 15173 RVA: 0x000C9FB4 File Offset: 0x000C81B4
private unsafe static bool DoubleWordsAreSwapped()
{
double num = 1.0;
return *((ref num) + 2) == 240;
}
/// <summary>Converts the specified double-precision floating point number to a 64-bit signed integer.</summary>
/// <returns>A 64-bit signed integer whose value is equivalent to <paramref name="value" />.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B46 RID: 15174 RVA: 0x000C9FDC File Offset: 0x000C81DC
public static long DoubleToInt64Bits(double value)
{
return BitConverter.ToInt64(BitConverter.GetBytes(value), 0);
}
/// <summary>Converts the specified 64-bit signed integer to a double-precision floating point number.</summary>
/// <returns>A double-precision floating point number whose value is equivalent to <paramref name="value" />.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B47 RID: 15175 RVA: 0x000C9FEC File Offset: 0x000C81EC
public static double Int64BitsToDouble(long value)
{
return BitConverter.ToDouble(BitConverter.GetBytes(value), 0);
}
// Token: 0x06003B48 RID: 15176 RVA: 0x000C9FFC File Offset: 0x000C81FC
internal static double InternalInt64BitsToDouble(long value)
{
return BitConverter.SwappableToDouble(BitConverter.GetBytes(value), 0);
}
// Token: 0x06003B49 RID: 15177 RVA: 0x000CA00C File Offset: 0x000C820C
private unsafe static byte[] GetBytes(byte* ptr, int count)
{
byte[] array = new byte[count];
for (int i = 0; i < count; i++)
{
array[i] = ptr[i];
}
return array;
}
/// <summary>Returns the specified Boolean value as an array of bytes.</summary>
/// <returns>An array of bytes with length 1.</returns>
/// <param name="value">A Boolean value. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B4A RID: 15178 RVA: 0x000CA03C File Offset: 0x000C823C
public unsafe static byte[] GetBytes(bool value)
{
return BitConverter.GetBytes((byte*)(&value), 1);
}
/// <summary>Returns the specified Unicode character value as an array of bytes.</summary>
/// <returns>An array of bytes with length 2.</returns>
/// <param name="value">A character to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B4B RID: 15179 RVA: 0x000CA048 File Offset: 0x000C8248
public unsafe static byte[] GetBytes(char value)
{
return BitConverter.GetBytes((byte*)(&value), 2);
}
/// <summary>Returns the specified 16-bit signed integer value as an array of bytes.</summary>
/// <returns>An array of bytes with length 2.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B4C RID: 15180 RVA: 0x000CA054 File Offset: 0x000C8254
public unsafe static byte[] GetBytes(short value)
{
return BitConverter.GetBytes((byte*)(&value), 2);
}
/// <summary>Returns the specified 32-bit signed integer value as an array of bytes.</summary>
/// <returns>An array of bytes with length 4.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B4D RID: 15181 RVA: 0x000CA060 File Offset: 0x000C8260
public unsafe static byte[] GetBytes(int value)
{
return BitConverter.GetBytes((byte*)(&value), 4);
}
/// <summary>Returns the specified 64-bit signed integer value as an array of bytes.</summary>
/// <returns>An array of bytes with length 8.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B4E RID: 15182 RVA: 0x000CA06C File Offset: 0x000C826C
public unsafe static byte[] GetBytes(long value)
{
return BitConverter.GetBytes((byte*)(&value), 8);
}
/// <summary>Returns the specified 16-bit unsigned integer value as an array of bytes.</summary>
/// <returns>An array of bytes with length 2.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B4F RID: 15183 RVA: 0x000CA078 File Offset: 0x000C8278
[CLSCompliant(false)]
public unsafe static byte[] GetBytes(ushort value)
{
return BitConverter.GetBytes((byte*)(&value), 2);
}
/// <summary>Returns the specified 32-bit unsigned integer value as an array of bytes.</summary>
/// <returns>An array of bytes with length 4.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B50 RID: 15184 RVA: 0x000CA084 File Offset: 0x000C8284
[CLSCompliant(false)]
public unsafe static byte[] GetBytes(uint value)
{
return BitConverter.GetBytes((byte*)(&value), 4);
}
/// <summary>Returns the specified 64-bit unsigned integer value as an array of bytes.</summary>
/// <returns>An array of bytes with length 8.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B51 RID: 15185 RVA: 0x000CA090 File Offset: 0x000C8290
[CLSCompliant(false)]
public unsafe static byte[] GetBytes(ulong value)
{
return BitConverter.GetBytes((byte*)(&value), 8);
}
/// <summary>Returns the specified single-precision floating point value as an array of bytes.</summary>
/// <returns>An array of bytes with length 4.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B52 RID: 15186 RVA: 0x000CA09C File Offset: 0x000C829C
public unsafe static byte[] GetBytes(float value)
{
return BitConverter.GetBytes((byte*)(&value), 4);
}
/// <summary>Returns the specified double-precision floating point value as an array of bytes.</summary>
/// <returns>An array of bytes with length 8.</returns>
/// <param name="value">The number to convert. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B53 RID: 15187 RVA: 0x000CA0A8 File Offset: 0x000C82A8
public unsafe static byte[] GetBytes(double value)
{
if (BitConverter.SwappedWordsInDouble)
{
return new byte[]
{
*((ref value) + 4),
*((ref value) + 5),
*((ref value) + 6),
*((ref value) + 7),
(byte)value,
*((ref value) + 1),
*((ref value) + 2),
*((ref value) + 3)
};
}
return BitConverter.GetBytes((byte*)(&value), 8);
}
// Token: 0x06003B54 RID: 15188 RVA: 0x000CA10C File Offset: 0x000C830C
private unsafe static void PutBytes(byte* dst, byte[] src, int start_index, int count)
{
if (src == null)
{
throw new ArgumentNullException("value");
}
if (start_index < 0 || start_index > src.Length - 1)
{
throw new ArgumentOutOfRangeException("startIndex", "Index was out of range. Must be non-negative and less than the size of the collection.");
}
if (src.Length - count < start_index)
{
throw new ArgumentException("Destination array is not long enough to copy all the items in the collection. Check array index and length.");
}
for (int i = 0; i < count; i++)
{
dst[i] = src[i + start_index];
}
}
/// <summary>Returns a Boolean value converted from one byte at a specified position in a byte array.</summary>
/// <returns>true if the byte at <paramref name="startIndex" /> in <paramref name="value" /> is nonzero; otherwise, false.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B55 RID: 15189 RVA: 0x000CA180 File Offset: 0x000C8380
public static bool ToBoolean(byte[] value, int startIndex)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
if (startIndex < 0 || startIndex > value.Length - 1)
{
throw new ArgumentOutOfRangeException("startIndex", "Index was out of range. Must be non-negative and less than the size of the collection.");
}
return value[startIndex] != 0;
}
/// <summary>Returns a Unicode character converted from two bytes at a specified position in a byte array.</summary>
/// <returns>A character formed by two bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> equals the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B56 RID: 15190 RVA: 0x000CA1CC File Offset: 0x000C83CC
public unsafe static char ToChar(byte[] value, int startIndex)
{
char c;
BitConverter.PutBytes((byte*)(&c), value, startIndex, 2);
return c;
}
/// <summary>Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.</summary>
/// <returns>A 16-bit signed integer formed by two bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> equals the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B57 RID: 15191 RVA: 0x000CA1E4 File Offset: 0x000C83E4
public unsafe static short ToInt16(byte[] value, int startIndex)
{
short num;
BitConverter.PutBytes((byte*)(&num), value, startIndex, 2);
return num;
}
/// <summary>Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.</summary>
/// <returns>A 32-bit signed integer formed by four bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> is greater than or equal to the length of <paramref name="value" /> minus 3, and is less than or equal to the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B58 RID: 15192 RVA: 0x000CA1FC File Offset: 0x000C83FC
public unsafe static int ToInt32(byte[] value, int startIndex)
{
int num;
BitConverter.PutBytes((byte*)(&num), value, startIndex, 4);
return num;
}
/// <summary>Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array.</summary>
/// <returns>A 64-bit signed integer formed by eight bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> is greater than or equal to the length of <paramref name="value" /> minus 7, and is less than or equal to the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B59 RID: 15193 RVA: 0x000CA214 File Offset: 0x000C8414
public unsafe static long ToInt64(byte[] value, int startIndex)
{
long num;
BitConverter.PutBytes((byte*)(&num), value, startIndex, 8);
return num;
}
/// <summary>Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.</summary>
/// <returns>A 16-bit unsigned integer formed by two bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">The array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> equals the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B5A RID: 15194 RVA: 0x000CA22C File Offset: 0x000C842C
[CLSCompliant(false)]
public unsafe static ushort ToUInt16(byte[] value, int startIndex)
{
ushort num;
BitConverter.PutBytes((byte*)(&num), value, startIndex, 2);
return num;
}
/// <summary>Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.</summary>
/// <returns>A 32-bit unsigned integer formed by four bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> is greater than or equal to the length of <paramref name="value" /> minus 3, and is less than or equal to the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B5B RID: 15195 RVA: 0x000CA244 File Offset: 0x000C8444
[CLSCompliant(false)]
public unsafe static uint ToUInt32(byte[] value, int startIndex)
{
uint num;
BitConverter.PutBytes((byte*)(&num), value, startIndex, 4);
return num;
}
/// <summary>Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.</summary>
/// <returns>A 64-bit unsigned integer formed by the eight bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> is greater than or equal to the length of <paramref name="value" /> minus 7, and is less than or equal to the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B5C RID: 15196 RVA: 0x000CA25C File Offset: 0x000C845C
[CLSCompliant(false)]
public unsafe static ulong ToUInt64(byte[] value, int startIndex)
{
ulong num;
BitConverter.PutBytes((byte*)(&num), value, startIndex, 8);
return num;
}
/// <summary>Returns a single-precision floating point number converted from four bytes at a specified position in a byte array.</summary>
/// <returns>A single-precision floating point number formed by four bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> is greater than or equal to the length of <paramref name="value" /> minus 3, and is less than or equal to the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B5D RID: 15197 RVA: 0x000CA274 File Offset: 0x000C8474
public unsafe static float ToSingle(byte[] value, int startIndex)
{
float num;
BitConverter.PutBytes((byte*)(&num), value, startIndex, 4);
return num;
}
/// <summary>Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array.</summary>
/// <returns>A double precision floating point number formed by eight bytes beginning at <paramref name="startIndex" />.</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="startIndex" /> is greater than or equal to the length of <paramref name="value" /> minus 7, and is less than or equal to the length of <paramref name="value" /> minus 1.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B5E RID: 15198 RVA: 0x000CA28C File Offset: 0x000C848C
public unsafe static double ToDouble(byte[] value, int startIndex)
{
double num;
if (!BitConverter.SwappedWordsInDouble)
{
BitConverter.PutBytes((byte*)(&num), value, startIndex, 8);
return num;
}
if (value == null)
{
throw new ArgumentNullException("value");
}
if (startIndex < 0 || startIndex > value.Length - 1)
{
throw new ArgumentOutOfRangeException("startIndex", "Index was out of range. Must be non-negative and less than the size of the collection.");
}
if (value.Length - 8 < startIndex)
{
throw new ArgumentException("Destination array is not long enough to copy all the items in the collection. Check array index and length.");
}
num = (double)value[startIndex + 4];
*((ref num) + 1) = value[startIndex + 5];
*((ref num) + 2) = value[startIndex + 6];
*((ref num) + 3) = value[startIndex + 7];
*((ref num) + 4) = value[startIndex];
*((ref num) + 5) = value[startIndex + 1];
*((ref num) + 6) = value[startIndex + 2];
*((ref num) + 7) = value[startIndex + 3];
return num;
}
// Token: 0x06003B5F RID: 15199 RVA: 0x000CA340 File Offset: 0x000C8540
internal unsafe static double SwappableToDouble(byte[] value, int startIndex)
{
if (BitConverter.SwappedWordsInDouble)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
if (startIndex < 0 || startIndex > value.Length - 1)
{
throw new ArgumentOutOfRangeException("startIndex", "Index was out of range. Must be non-negative and less than the size of the collection.");
}
if (value.Length - 8 < startIndex)
{
throw new ArgumentException("Destination array is not long enough to copy all the items in the collection. Check array index and length.");
}
double num = (double)value[startIndex + 4];
*((ref num) + 1) = value[startIndex + 5];
*((ref num) + 2) = value[startIndex + 6];
*((ref num) + 3) = value[startIndex + 7];
*((ref num) + 4) = value[startIndex];
*((ref num) + 5) = value[startIndex + 1];
*((ref num) + 6) = value[startIndex + 2];
*((ref num) + 7) = value[startIndex + 3];
return num;
}
else
{
double num;
if (BitConverter.IsLittleEndian)
{
BitConverter.PutBytes((byte*)(&num), value, startIndex, 8);
return num;
}
if (value == null)
{
throw new ArgumentNullException("value");
}
if (startIndex < 0 || startIndex > value.Length - 1)
{
throw new ArgumentOutOfRangeException("startIndex", "Index was out of range. Must be non-negative and less than the size of the collection.");
}
if (value.Length - 8 < startIndex)
{
throw new ArgumentException("Destination array is not long enough to copy all the items in the collection. Check array index and length.");
}
num = (double)value[startIndex + 7];
*((ref num) + 1) = value[startIndex + 6];
*((ref num) + 2) = value[startIndex + 5];
*((ref num) + 3) = value[startIndex + 4];
*((ref num) + 4) = value[startIndex + 3];
*((ref num) + 5) = value[startIndex + 2];
*((ref num) + 6) = value[startIndex + 1];
*((ref num) + 7) = value[startIndex];
return num;
}
}
/// <summary>Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation.</summary>
/// <returns>A <see cref="T:System.String" /> of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in <paramref name="value" />; for example, "7F-2C-4A".</returns>
/// <param name="value">An array of bytes. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B60 RID: 15200 RVA: 0x000CA490 File Offset: 0x000C8690
public static string ToString(byte[] value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
return BitConverter.ToString(value, 0, value.Length);
}
/// <summary>Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation.</summary>
/// <returns>A <see cref="T:System.String" /> of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of <paramref name="value" />; for example, "7F-2C-4A".</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> is less than zero or greater than the length of <paramref name="value" /> minus 1. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B61 RID: 15201 RVA: 0x000CA4B0 File Offset: 0x000C86B0
public static string ToString(byte[] value, int startIndex)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
return BitConverter.ToString(value, startIndex, value.Length - startIndex);
}
/// <summary>Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation.</summary>
/// <returns>A <see cref="T:System.String" /> of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of <paramref name="value" />; for example, "7F-2C-4A".</returns>
/// <param name="value">An array of bytes. </param>
/// <param name="startIndex">The starting position within <paramref name="value" />. </param>
/// <param name="length">The number of array elements in <paramref name="value" /> to convert. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="value" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="startIndex" /> or <paramref name="length" /> is less than zero.-or-<paramref name="startIndex" /> is greater than zero and is greater than or equal to the length of <paramref name="value" />.</exception>
/// <exception cref="T:System.ArgumentException">The combination of <paramref name="startIndex" /> and <paramref name="length" /> does not specify a position within <paramref name="value" />; that is, the <paramref name="startIndex" /> parameter is greater than the length of <paramref name="value" /> minus the <paramref name="length" /> parameter.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06003B62 RID: 15202 RVA: 0x000CA4D0 File Offset: 0x000C86D0
public static string ToString(byte[] value, int startIndex, int length)
{
if (value == null)
{
throw new ArgumentNullException("byteArray");
}
if (startIndex < 0 || startIndex >= value.Length)
{
if (startIndex == 0 && value.Length == 0)
{
return string.Empty;
}
throw new ArgumentOutOfRangeException("startIndex", "Index was out of range. Must be non-negative and less than the size of the collection.");
}
else
{
if (length < 0)
{
throw new ArgumentOutOfRangeException("length", "Value must be positive.");
}
if (startIndex > value.Length - length)
{
throw new ArgumentException("startIndex + length > value.Length");
}
if (length == 0)
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder(length * 3 - 1);
int num = startIndex + length;
for (int i = startIndex; i < num; i++)
{
if (i > startIndex)
{
stringBuilder.Append('-');
}
char c = (char)((value[i] >> 4) & 15);
char c2 = (char)(value[i] & 15);
if (c < '\n')
{
c += '0';
}
else
{
c -= '\n';
c += 'A';
}
if (c2 < '\n')
{
c2 += '0';
}
else
{
c2 -= '\n';
c2 += 'A';
}
stringBuilder.Append(c);
stringBuilder.Append(c2);
}
return stringBuilder.ToString();
}
}
// Token: 0x040017C3 RID: 6083
private static readonly bool SwappedWordsInDouble = BitConverter.DoubleWordsAreSwapped();
/// <summary>Indicates the byte order ("endianess") in which data is stored in this computer architecture.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x040017C4 RID: 6084
public static readonly bool IsLittleEndian = BitConverter.AmILittleEndian();
}
}