Files
2026-06-04 11:42:34 +02:00

528 lines
25 KiB
C#

using System;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System
{
/// <summary>Represents a 16-bit signed integer.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x02000015 RID: 21
[ComVisible(true)]
[Serializable]
public struct Int16 : IFormattable, IConvertible, IComparable, IComparable<short>, IEquatable<short>
{
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToBoolean(System.IFormatProvider)" />. </summary>
/// <returns>true if the value of the current instance is not zero; otherwise, false.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000130 RID: 304 RVA: 0x00005898 File Offset: 0x00003A98
bool IConvertible.ToBoolean(IFormatProvider provider)
{
return Convert.ToBoolean(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToByte(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to a <see cref="T:System.Byte" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000131 RID: 305 RVA: 0x000058A4 File Offset: 0x00003AA4
byte IConvertible.ToByte(IFormatProvider provider)
{
return Convert.ToByte(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToChar(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to a <see cref="T:System.Char" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000132 RID: 306 RVA: 0x000058B0 File Offset: 0x00003AB0
char IConvertible.ToChar(IFormatProvider provider)
{
return Convert.ToChar(this);
}
/// <summary>This conversion is not supported. Attempting to use this method throws an <see cref="T:System.InvalidCastException" />.</summary>
/// <returns>This conversion is not supported. No value is returned.</returns>
/// <param name="provider">This parameter is ignored.</param>
/// <exception cref="T:System.InvalidCastException">In all cases.</exception>
// Token: 0x06000133 RID: 307 RVA: 0x000058BC File Offset: 0x00003ABC
DateTime IConvertible.ToDateTime(IFormatProvider provider)
{
return Convert.ToDateTime(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToDecimal(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to a <see cref="T:System.Decimal" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000134 RID: 308 RVA: 0x000058C8 File Offset: 0x00003AC8
decimal IConvertible.ToDecimal(IFormatProvider provider)
{
return Convert.ToDecimal(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToDouble(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to a <see cref="T:System.Double" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000135 RID: 309 RVA: 0x000058D4 File Offset: 0x00003AD4
double IConvertible.ToDouble(IFormatProvider provider)
{
return Convert.ToDouble(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToInt16(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, unchanged.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000136 RID: 310 RVA: 0x000058E0 File Offset: 0x00003AE0
short IConvertible.ToInt16(IFormatProvider provider)
{
return Convert.ToInt16(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToInt32(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to an <see cref="T:System.Int32" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000137 RID: 311 RVA: 0x000058EC File Offset: 0x00003AEC
int IConvertible.ToInt32(IFormatProvider provider)
{
return Convert.ToInt32(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToInt64(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to an <see cref="T:System.Int64" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000138 RID: 312 RVA: 0x000058F8 File Offset: 0x00003AF8
long IConvertible.ToInt64(IFormatProvider provider)
{
return Convert.ToInt64(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToSByte(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to an <see cref="T:System.SByte" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x06000139 RID: 313 RVA: 0x00005904 File Offset: 0x00003B04
sbyte IConvertible.ToSByte(IFormatProvider provider)
{
return Convert.ToSByte(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToSingle(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to a <see cref="T:System.Single" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x0600013A RID: 314 RVA: 0x00005910 File Offset: 0x00003B10
float IConvertible.ToSingle(IFormatProvider provider)
{
return Convert.ToSingle(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToType(System.Type,System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to <paramref name="type" />.</returns>
/// <param name="type">The type to which to convert this <see cref="T:System.Int16" /> value.</param>
/// <param name="provider">An <see cref="T:System.IFormatProvider" /> implementation that supplies information about the format of the returned value.</param>
// Token: 0x0600013B RID: 315 RVA: 0x0000591C File Offset: 0x00003B1C
object IConvertible.ToType(Type targetType, IFormatProvider provider)
{
if (targetType == null)
{
throw new ArgumentNullException("targetType");
}
return Convert.ToType(this, targetType, provider, false);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToUInt16(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, unchanged.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x0600013C RID: 316 RVA: 0x0000594C File Offset: 0x00003B4C
ushort IConvertible.ToUInt16(IFormatProvider provider)
{
return Convert.ToUInt16(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToUInt32(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to a <see cref="T:System.UInt32" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x0600013D RID: 317 RVA: 0x00005958 File Offset: 0x00003B58
uint IConvertible.ToUInt32(IFormatProvider provider)
{
return Convert.ToUInt32(this);
}
/// <summary>For a description of this member, see <see cref="M:System.IConvertible.ToUInt64(System.IFormatProvider)" />. </summary>
/// <returns>The value of the current instance, converted to a <see cref="T:System.UInt64" />.</returns>
/// <param name="provider">This parameter is ignored.</param>
// Token: 0x0600013E RID: 318 RVA: 0x00005964 File Offset: 0x00003B64
ulong IConvertible.ToUInt64(IFormatProvider provider)
{
return Convert.ToUInt64(this);
}
/// <summary>Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the object.</summary>
/// <returns>A signed number indicating the relative values of this instance and <paramref name="value" />.Return Value Description Less than zero This instance is less than <paramref name="value" />. Zero This instance is equal to <paramref name="value" />. Greater than zero This instance is greater than <paramref name="value" />.-or- <paramref name="value" /> is null. </returns>
/// <param name="value">An object to compare, or null. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="value" /> is not an <see cref="T:System.Int16" />. </exception>
/// <filterpriority>2</filterpriority>
// Token: 0x0600013F RID: 319 RVA: 0x00005970 File Offset: 0x00003B70
public int CompareTo(object value)
{
if (value == null)
{
return 1;
}
if (!(value is short))
{
throw new ArgumentException(Locale.GetText("Value is not a System.Int16"));
}
short num = (short)value;
if (this == num)
{
return 0;
}
if (this > num)
{
return 1;
}
return -1;
}
/// <summary>Returns a value indicating whether this instance is equal to a specified object.</summary>
/// <returns>true if <paramref name="obj" /> is an instance of <see cref="T:System.Int16" /> and equals the value of this instance; otherwise, false.</returns>
/// <param name="obj">An object to compare to this instance. </param>
/// <filterpriority>2</filterpriority>
// Token: 0x06000140 RID: 320 RVA: 0x000059BC File Offset: 0x00003BBC
public override bool Equals(object obj)
{
return obj is short && (short)obj == this;
}
/// <summary>Returns the hash code for this instance.</summary>
/// <returns>A 32-bit signed integer hash code.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x06000141 RID: 321 RVA: 0x000059D8 File Offset: 0x00003BD8
public override int GetHashCode()
{
return (int)this;
}
/// <summary>Compares this instance to a specified 16-bit signed integer and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified 16-bit signed integer.</summary>
/// <returns>A signed number indicating the relative values of this instance and <paramref name="value" />.Return Value Description Less than zero This instance is less than <paramref name="value" />. Zero This instance is equal to <paramref name="value" />. Greater than zero This instance is greater than <paramref name="value" />. </returns>
/// <param name="value">An integer to compare. </param>
/// <filterpriority>2</filterpriority>
// Token: 0x06000142 RID: 322 RVA: 0x000059DC File Offset: 0x00003BDC
public int CompareTo(short value)
{
if (this == value)
{
return 0;
}
if (this > value)
{
return 1;
}
return -1;
}
/// <summary>Returns a value indicating whether this instance is equal to a specified <see cref="T:System.Int16" /> value.</summary>
/// <returns>true if <paramref name="obj" /> has the same value as this instance; otherwise, false.</returns>
/// <param name="obj">An <see cref="T:System.Int16" /> value to compare to this instance.</param>
/// <filterpriority>2</filterpriority>
// Token: 0x06000143 RID: 323 RVA: 0x000059F4 File Offset: 0x00003BF4
public bool Equals(short obj)
{
return obj == this;
}
// Token: 0x06000144 RID: 324 RVA: 0x000059FC File Offset: 0x00003BFC
internal static bool Parse(string s, bool tryParse, out short result, out Exception exc)
{
short num = 0;
int num2 = 1;
bool flag = false;
result = 0;
exc = null;
if (s == null)
{
if (!tryParse)
{
exc = new ArgumentNullException("s");
}
return false;
}
int length = s.Length;
int i;
char c;
for (i = 0; i < length; i++)
{
c = s[i];
if (!char.IsWhiteSpace(c))
{
break;
}
}
if (i == length)
{
if (!tryParse)
{
exc = int.GetFormatException();
}
return false;
}
c = s[i];
if (c == '+')
{
i++;
}
else if (c == '-')
{
num2 = -1;
i++;
}
while (i < length)
{
c = s[i];
if (c >= '0' && c <= '9')
{
byte b = (byte)(c - '0');
if (num <= 3276)
{
if (num != 3276)
{
num = num * 10 + (short)b;
flag = true;
goto IL_154;
}
if (b <= 7 || (num2 != 1 && b <= 8))
{
if (num2 == -1)
{
num = (short)((int)num * num2 * 10 - (int)b);
}
else
{
num = num * 10 + (short)b;
}
if (int.ProcessTrailingWhitespace(tryParse, s, i + 1, ref exc))
{
result = num;
return true;
}
}
}
if (!tryParse)
{
exc = new OverflowException("Value is too large");
}
return false;
}
if (!int.ProcessTrailingWhitespace(tryParse, s, i, ref exc))
{
return false;
}
IL_154:
i++;
}
if (!flag)
{
if (!tryParse)
{
exc = int.GetFormatException();
}
return false;
}
if (num2 == -1)
{
result = (short)((int)num * num2);
}
else
{
result = num;
}
return true;
}
/// <summary>Converts the string representation of a number in a specified culture-specific format to its 16-bit signed integer equivalent.</summary>
/// <returns>A 16-bit signed integer equivalent to the number specified in <paramref name="s" />.</returns>
/// <param name="s">A string containing a number to convert. </param>
/// <param name="provider">An <see cref="T:System.IFormatProvider" /> that supplies culture-specific formatting information about <paramref name="s" />. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="s" /> is null. </exception>
/// <exception cref="T:System.FormatException">
/// <paramref name="s" /> is not in the correct format. </exception>
/// <exception cref="T:System.OverflowException">
/// <paramref name="s" /> represents a number less than <see cref="F:System.Int16.MinValue" /> or greater than <see cref="F:System.Int16.MaxValue" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06000145 RID: 325 RVA: 0x00005BA8 File Offset: 0x00003DA8
public static short Parse(string s, IFormatProvider provider)
{
return short.Parse(s, NumberStyles.Integer, provider);
}
/// <summary>Converts the string representation of a number in a specified style to its 16-bit signed integer equivalent.</summary>
/// <returns>A 16-bit signed integer equivalent to the number specified in <paramref name="s" />.</returns>
/// <param name="s">A string containing a number to convert. </param>
/// <param name="style">A bitwise combination of the enumeration values that indicates the style elements that can be present in <paramref name="s" />. A typical value to specify is <see cref="F:System.Globalization.NumberStyles.Integer" />.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="s" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="style" /> is not a <see cref="T:System.Globalization.NumberStyles" /> value. -or-<paramref name="style" /> is not a combination of <see cref="F:System.Globalization.NumberStyles.AllowHexSpecifier" /> and <see cref="F:System.Globalization.NumberStyles.HexNumber" /> values.</exception>
/// <exception cref="T:System.FormatException">
/// <paramref name="s" /> is not in a format compliant with <paramref name="style" />. </exception>
/// <exception cref="T:System.OverflowException">
/// <paramref name="s" /> represents a number less than <see cref="F:System.Int16.MinValue" /> or greater than <see cref="F:System.Int16.MaxValue" />. -or-<paramref name="s" /> includes non-zero fractional digits.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06000146 RID: 326 RVA: 0x00005BB4 File Offset: 0x00003DB4
public static short Parse(string s, NumberStyles style)
{
return short.Parse(s, style, null);
}
/// <summary>Converts the string representation of a number in a specified style and culture-specific format to its 16-bit signed integer equivalent.</summary>
/// <returns>A 16-bit signed integer equivalent to the number specified in <paramref name="s" />.</returns>
/// <param name="s">A string containing a number to convert. </param>
/// <param name="style">A bitwise combination of enumeration values that indicates the style elements that can be present in <paramref name="s" />. A typical value to specify is <see cref="F:System.Globalization.NumberStyles.Integer" />.</param>
/// <param name="provider">An <see cref="T:System.IFormatProvider" /> that supplies culture-specific formatting information about <paramref name="s" />. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="s" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="style" /> is not a <see cref="T:System.Globalization.NumberStyles" /> value. -or-<paramref name="style" /> is not a combination of <see cref="F:System.Globalization.NumberStyles.AllowHexSpecifier" /> and <see cref="F:System.Globalization.NumberStyles.HexNumber" /> values.</exception>
/// <exception cref="T:System.FormatException">
/// <paramref name="s" /> is not in a format compliant with <paramref name="style" />. </exception>
/// <exception cref="T:System.OverflowException">
/// <paramref name="s" /> represents a number less than <see cref="F:System.Int16.MinValue" /> or greater than <see cref="F:System.Int16.MaxValue" />. -or-<paramref name="s" /> includes non-zero fractional digits.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06000147 RID: 327 RVA: 0x00005BC0 File Offset: 0x00003DC0
public static short Parse(string s, NumberStyles style, IFormatProvider provider)
{
int num = int.Parse(s, style, provider);
if (num > 32767 || num < -32768)
{
throw new OverflowException("Value too large or too small.");
}
return (short)num;
}
/// <summary>Converts the string representation of a number to its 16-bit signed integer equivalent.</summary>
/// <returns>A 16-bit signed integer equivalent to the number contained in <paramref name="s" />.</returns>
/// <param name="s">A string containing a number to convert. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="s" /> is null. </exception>
/// <exception cref="T:System.FormatException">
/// <paramref name="s" /> is not in the correct format. </exception>
/// <exception cref="T:System.OverflowException">
/// <paramref name="s" /> represents a number less than <see cref="F:System.Int16.MinValue" /> or greater than <see cref="F:System.Int16.MaxValue" />. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x06000148 RID: 328 RVA: 0x00005BFC File Offset: 0x00003DFC
public static short Parse(string s)
{
short num;
Exception ex;
if (!short.Parse(s, false, out num, out ex))
{
throw ex;
}
return num;
}
/// <summary>Converts the string representation of a number to its 16-bit signed integer equivalent. A return value indicates whether the conversion succeeded or failed.</summary>
/// <returns>true if <paramref name="s" /> was converted successfully; otherwise, false.</returns>
/// <param name="s">A string containing a number to convert. </param>
/// <param name="result">When this method returns, contains the 16-bit signed integer value equivalent to the number contained in <paramref name="s" />, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the <paramref name="s" /> parameter is null, is not of the correct format, or represents a number less than <see cref="F:System.Int16.MinValue" /> or greater than <see cref="F:System.Int16.MaxValue" />. This parameter is passed uninitialized. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x06000149 RID: 329 RVA: 0x00005C1C File Offset: 0x00003E1C
public static bool TryParse(string s, out short result)
{
Exception ex;
if (!short.Parse(s, true, out result, out ex))
{
result = 0;
return false;
}
return true;
}
/// <summary>Converts the string representation of a number in a specified style and culture-specific format to its 16-bit signed integer equivalent. A return value indicates whether the conversion succeeded or failed.</summary>
/// <returns>true if <paramref name="s" /> was converted successfully; otherwise, false.</returns>
/// <param name="s">A string containing a number to convert. The string is interpreted using the style specified by <paramref name="style" />.</param>
/// <param name="style">A bitwise combination of enumeration values that indicates the style elements that can be present in <paramref name="s" />. A typical value to specify is <see cref="F:System.Globalization.NumberStyles.Integer" />.</param>
/// <param name="provider">An object that supplies culture-specific formatting information about <paramref name="s" />. </param>
/// <param name="result">When this method returns, contains the 16-bit signed integer value equivalent to the number contained in <paramref name="s" />, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the <paramref name="s" /> parameter is null, is not in a format compliant with <paramref name="style" />, or represents a number less than <see cref="F:System.Int16.MinValue" /> or greater than <see cref="F:System.Int16.MaxValue" />. This parameter is passed uninitialized. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="style" /> is not a <see cref="T:System.Globalization.NumberStyles" /> value. -or-<paramref name="style" /> is not a combination of <see cref="F:System.Globalization.NumberStyles.AllowHexSpecifier" /> and <see cref="F:System.Globalization.NumberStyles.HexNumber" /> values.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x0600014A RID: 330 RVA: 0x00005C40 File Offset: 0x00003E40
public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out short result)
{
result = 0;
int num;
if (!int.TryParse(s, style, provider, out num))
{
return false;
}
if (num > 32767 || num < -32768)
{
return false;
}
result = (short)num;
return true;
}
/// <summary>Converts the numeric value of this instance to its equivalent string representation.</summary>
/// <returns>The string representation of the value of this instance, consisting of a minus sign if the value is negative, and a sequence of digits ranging from 0 to 9 with no leading zeroes.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x0600014B RID: 331 RVA: 0x00005C80 File Offset: 0x00003E80
public override string ToString()
{
return NumberFormatter.NumberToString((int)this, null);
}
/// <summary>Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.</summary>
/// <returns>The string representation of the value of this instance as specified by <paramref name="provider" />.</returns>
/// <param name="provider">An <see cref="T:System.IFormatProvider" /> that supplies culture-specific formatting information. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x0600014C RID: 332 RVA: 0x00005C8C File Offset: 0x00003E8C
public string ToString(IFormatProvider provider)
{
return NumberFormatter.NumberToString((int)this, provider);
}
/// <summary>Converts the numeric value of this instance to its equivalent string representation, using the specified format.</summary>
/// <returns>The string representation of the value of this instance as specified by <paramref name="format" />.</returns>
/// <param name="format">A numeric format string (see Remarks).</param>
/// <filterpriority>1</filterpriority>
// Token: 0x0600014D RID: 333 RVA: 0x00005C98 File Offset: 0x00003E98
public string ToString(string format)
{
return this.ToString(format, null);
}
/// <summary>Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific formatting information.</summary>
/// <returns>The string representation of the value of this instance as specified by <paramref name="format" /> and <paramref name="provider" />.</returns>
/// <param name="format">A numeric format string (see Remarks).</param>
/// <param name="provider">An object that supplies culture-specific formatting information. </param>
/// <filterpriority>1</filterpriority>
// Token: 0x0600014E RID: 334 RVA: 0x00005CA4 File Offset: 0x00003EA4
public string ToString(string format, IFormatProvider provider)
{
return NumberFormatter.NumberToString(format, this, provider);
}
/// <summary>Returns the <see cref="T:System.TypeCode" /> for value type <see cref="T:System.Int16" />.</summary>
/// <returns>The enumerated constant, <see cref="F:System.TypeCode.Int16" />.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x0600014F RID: 335 RVA: 0x00005CB0 File Offset: 0x00003EB0
public TypeCode GetTypeCode()
{
return TypeCode.Int16;
}
/// <summary>Represents the largest possible value of an <see cref="T:System.Int16" />. This field is constant.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x04000018 RID: 24
public const short MaxValue = 32767;
/// <summary>Represents the smallest possible value of <see cref="T:System.Int16" />. This field is constant.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x04000019 RID: 25
public const short MinValue = -32768;
// Token: 0x0400001A RID: 26
internal short m_value;
}
}