10[TypeForwardedFrom(
"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
11public readonly
struct Int16 :
IComparable,
IConvertible,
ISpanFormattable,
IFormattable,
IComparable<short>,
IEquatable<short>,
IBinaryInteger<short>,
IBinaryNumber<short>,
IBitwiseOperators<short, short, short>,
INumber<short>,
IAdditionOperators<short, short, short>,
IAdditiveIdentity<short, short>,
IComparisonOperators<short, short>,
IEqualityOperators<short, short>,
IDecrementOperators<short>,
IDivisionOperators<short, short, short>,
IIncrementOperators<short>,
IModulusOperators<short, short, short>,
IMultiplicativeIdentity<short, short>,
IMultiplyOperators<short, short, short>,
ISpanParseable<short>,
IParseable<short>,
ISubtractionOperators<short, short, short>,
IUnaryNegationOperators<short, short>,
IUnaryPlusOperators<short, short>,
IShiftOperators<short, short>,
IMinMaxValue<short>,
ISignedNumber<short>
19 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
22 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
25 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
28 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
31 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
34 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
37 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
58 public override bool Equals([NotNullWhen(
true)]
object?
obj)
151 if (parsingStatus != 0)
155 if ((uint)(result - -32768 - ((
int)(style &
NumberStyles.AllowHexSpecifier) << 6)) > 65535u)
159 return (
short)result;
162 public static bool TryParse([NotNullWhen(
true)]
string?
s, out
short result)
201 result = (
short)result2;
285 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
288 return (
short)(left + right);
291 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
297 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
303 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
306 return (
short)((
value << (rotateAmount & 0xF)) | ((ushort)
value >> ((16 - rotateAmount) & 0xF)));
309 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
312 return (
short)(((ushort)
value >> (rotateAmount & 0xF)) | (
value << ((16 - rotateAmount) & 0xF)));
315 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
321 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
327 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
337 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
340 return (
short)(left & right);
343 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
346 return (
short)(left | right);
349 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
352 return (
short)(left ^ right);
355 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
358 return (
short)(~value);
361 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
367 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
370 return left <= right;
373 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
379 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
382 return left >= right;
385 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
391 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
394 return (
short)(left / right);
397 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
400 return left == right;
403 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
406 return left != right;
409 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
415 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
418 return (
short)(left % right);
421 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
424 return (
short)(left * right);
427 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
433 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
440 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
443 if (typeof(TOther) == typeof(
byte))
445 return (
byte)(object)
value;
449 if (typeof(TOther) == typeof(
char))
451 return (
short)(char)(
object)
value;
453 if (typeof(TOther) == typeof(decimal))
455 return (
short)(decimal)(
object)
value;
457 if (typeof(TOther) == typeof(
double))
459 return (
short)(double)(
object)
value;
461 if (typeof(TOther) == typeof(
short))
463 return (
short)(object)
value;
465 if (typeof(TOther) == typeof(
int))
467 return (
short)(int)(
object)
value;
469 if (typeof(TOther) == typeof(
long))
471 return (
short)(long)(
object)
value;
473 if (typeof(TOther) == typeof(
IntPtr))
477 if (typeof(TOther) == typeof(sbyte))
479 return (sbyte)(object)
value;
481 if (typeof(TOther) == typeof(
float))
483 return (
short)(float)(
object)
value;
485 if (typeof(TOther) == typeof(ushort))
487 return (
short)(ushort)(
object)
value;
489 if (typeof(TOther) == typeof(uint))
491 return (
short)(uint)(
object)
value;
493 if (typeof(TOther) == typeof(ulong))
495 return (
short)(ulong)(
object)
value;
497 if (typeof(TOther) == typeof(
UIntPtr))
507 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
510 if (typeof(TOther) == typeof(
byte))
512 return (
byte)(object)
value;
514 if (typeof(TOther) == typeof(
char))
516 char c = (char)(
object)
value;
521 return short.MaxValue;
523 if (typeof(TOther) == typeof(decimal))
525 decimal num = (decimal)(
object)
value;
528 if (!(num < -32768m))
532 return short.MinValue;
534 return short.MaxValue;
536 if (typeof(TOther) == typeof(
double))
538 double num2 = (double)(
object)
value;
539 if (!(num2 > 32767.0))
541 if (!(num2 < -32768.0))
545 return short.MinValue;
547 return short.MaxValue;
549 if (typeof(TOther) == typeof(
short))
551 return (
short)(object)
value;
553 if (typeof(TOther) == typeof(
int))
555 int num3 = (int)(
object)
value;
562 return short.MinValue;
564 return short.MaxValue;
566 if (typeof(TOther) == typeof(
long))
568 long num4 = (long)(
object)
value;
575 return short.MinValue;
577 return short.MaxValue;
579 if (typeof(TOther) == typeof(
IntPtr))
582 if ((nint)intPtr <= 32767)
584 if ((nint)intPtr >= -32768)
586 return (
short)(nint)intPtr;
590 return short.MaxValue;
592 if (typeof(TOther) == typeof(sbyte))
594 return (sbyte)(object)
value;
596 if (typeof(TOther) == typeof(
float))
598 float num5 = (float)(
object)
value;
599 if (!(num5 > 32767f))
601 if (!(num5 < -32768f))
605 return short.MinValue;
607 return short.MaxValue;
609 if (typeof(TOther) == typeof(ushort))
611 ushort num6 = (ushort)(
object)
value;
616 return short.MaxValue;
618 if (typeof(TOther) == typeof(uint))
620 uint num7 = (uint)(
object)
value;
621 if ((
long)num7 <= 32767
L)
625 return short.MaxValue;
627 if (typeof(TOther) == typeof(ulong))
629 ulong num8 = (ulong)(
object)
value;
634 return short.MaxValue;
636 if (typeof(TOther) == typeof(
UIntPtr))
639 if ((nuint)uIntPtr <= 32767)
641 return (
short)(nuint)uIntPtr;
650 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
653 if (typeof(TOther) == typeof(
byte))
655 return (
byte)(object)
value;
657 if (typeof(TOther) == typeof(
char))
659 return (
short)(char)(
object)
value;
661 if (typeof(TOther) == typeof(decimal))
663 return (
short)(decimal)(
object)
value;
665 if (typeof(TOther) == typeof(
double))
667 return (
short)(double)(
object)
value;
669 if (typeof(TOther) == typeof(
short))
671 return (
short)(object)
value;
673 if (typeof(TOther) == typeof(
int))
675 return (
short)(int)(
object)
value;
677 if (typeof(TOther) == typeof(
long))
679 return (
short)(long)(
object)
value;
681 if (typeof(TOther) == typeof(
IntPtr))
685 if (typeof(TOther) == typeof(sbyte))
687 return (sbyte)(object)
value;
689 if (typeof(TOther) == typeof(
float))
691 return (
short)(float)(
object)
value;
693 if (typeof(TOther) == typeof(ushort))
695 return (
short)(ushort)(
object)
value;
697 if (typeof(TOther) == typeof(uint))
699 return (
short)(uint)(
object)
value;
701 if (typeof(TOther) == typeof(ulong))
703 return (
short)(ulong)(
object)
value;
705 if (typeof(TOther) == typeof(
UIntPtr))
713 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
719 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
725 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
731 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
734 return Parse(
s, style, provider);
737 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
740 return Parse(
s, style, provider);
743 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
750 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
753 if (typeof(TOther) == typeof(
byte))
755 result = (byte)(
object)
value;
758 if (typeof(TOther) == typeof(
char))
760 char c = (char)(
object)
value;
769 if (typeof(TOther) == typeof(decimal))
771 decimal num = (decimal)(
object)
value;
772 if (num < -32768m || num > 32767m)
780 if (typeof(TOther) == typeof(
double))
782 double num2 = (double)(
object)
value;
783 if (num2 < -32768.0 || num2 > 32767.0)
788 result = (
short)num2;
791 if (typeof(TOther) == typeof(
short))
796 if (typeof(TOther) == typeof(
int))
798 int num3 = (int)(
object)
value;
799 if (num3 < -32768 || num3 > 32767)
804 result = (
short)num3;
807 if (typeof(TOther) == typeof(
long))
809 long num4 = (long)(
object)
value;
810 if (num4 < -32768 || num4 > 32767)
815 result = (
short)num4;
818 if (typeof(TOther) == typeof(
IntPtr))
821 if ((nint)intPtr < -32768 || (nint)intPtr > 32767)
826 result = (
short)(nint)intPtr;
829 if (typeof(TOther) == typeof(sbyte))
831 result = (sbyte)(
object)
value;
834 if (typeof(TOther) == typeof(
float))
836 float num5 = (float)(
object)
value;
837 if (num5 < -32768f || num5 > 32767f)
842 result = (
short)num5;
845 if (typeof(TOther) == typeof(ushort))
847 ushort num6 = (ushort)(
object)
value;
853 result = (
short)num6;
856 if (typeof(TOther) == typeof(uint))
858 uint num7 = (uint)(
object)
value;
859 if ((
long)num7 > 32767
L)
864 result = (
short)num7;
867 if (typeof(TOther) == typeof(ulong))
869 ulong num8 = (ulong)(
object)
value;
875 result = (
short)num8;
878 if (typeof(TOther) == typeof(
UIntPtr))
881 if ((nuint)uIntPtr > 32767)
886 result = (
short)(nuint)uIntPtr;
894 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
897 return TryParse(
s, style, provider, out result);
900 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
903 return TryParse(
s, style, provider, out result);
906 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
909 return Parse(
s, provider);
912 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
918 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
921 return (
short)(
value << shiftAmount);
924 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
927 return (
short)(
value >> shiftAmount);
930 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
936 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
942 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
945 return (
short)(left - right);
948 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
951 return (
short)(-
value);
954 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
static decimal ToDecimal(object? value)
static long ToInt64(object? value)
static float ToSingle(object? value)
static int ToInt32(object? value)
static byte ToByte(object? value)
static uint ToUInt32(object? value)
static ulong ToUInt64(object? value)
static char ToChar(object? value)
static ushort ToUInt16(object? value)
static sbyte ToSByte(object? value)
static double ToDouble(object? value)
static bool ToBoolean([NotNullWhen(true)] object? value)
static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
static byte Clamp(byte value, byte min, byte max)
static byte Min(byte val1, byte val2)
static double Abs(double value)
static int DivRem(int a, int b, out int result)
static int Sign(decimal value)
static byte Max(byte val1, byte val2)
static void ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type=TypeCode.Empty)
static void ThrowOverflowException(TypeCode type)
static string FormatInt32(int value, int hexMask, string format, IFormatProvider provider)
static string Int32ToDecStr(int value)
static ParsingStatus TryParseInt32(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info, out int result)
static bool TryFormatInt32(int value, int hexMask, ReadOnlySpan< char > format, IFormatProvider provider, Span< char > destination, out int charsWritten)
static int TrailingZeroCount(int value)
static bool IsPow2(int value)
static int PopCount(uint value)
static int Log2(uint value)
static int LeadingZeroCount(uint value)
static string Arg_MustBeInt16
static string InvalidCast_FromTo
static string Format(string resourceFormat, object p1)
static void ThrowNotSupportedException(ExceptionResource resource)
static void ThrowValueArgumentOutOfRange_NeedNonNegNumException()
static void ThrowArgumentNullException(string name)
static TResult AdditiveIdentity
static TSelf RotateRight(TSelf value, int rotateAmount)
static TSelf LeadingZeroCount(TSelf value)
static TSelf PopCount(TSelf value)
static TSelf TrailingZeroCount(TSelf value)
static TSelf RotateLeft(TSelf value, int rotateAmount)
static bool IsPow2(TSelf value)
static TSelf Log2(TSelf value)
short ToInt16(IFormatProvider? provider)
char ToChar(IFormatProvider? provider)
byte ToByte(IFormatProvider? provider)
decimal ToDecimal(IFormatProvider? provider)
object ToType(Type conversionType, IFormatProvider? provider)
uint ToUInt32(IFormatProvider? provider)
DateTime ToDateTime(IFormatProvider? provider)
int ToInt32(IFormatProvider? provider)
long ToInt64(IFormatProvider? provider)
ushort ToUInt16(IFormatProvider? provider)
double ToDouble(IFormatProvider? provider)
float ToSingle(IFormatProvider? provider)
sbyte ToSByte(IFormatProvider? provider)
ulong ToUInt64(IFormatProvider? provider)
bool ToBoolean(IFormatProvider? provider)
static TResult MultiplicativeIdentity
static TSelf Max(TSelf x, TSelf y)
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, NumberStyles style, IFormatProvider? provider)
static TSelf Sign(TSelf value)
static TSelf Min(TSelf x, TSelf y)
static TSelf Abs(TSelf value)
static TSelf Clamp(TSelf value, TSelf min, TSelf max)
static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, IFormatProvider? provider)
static bool TryParse(ReadOnlySpan< char > s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(ReadOnlySpan< char > s, IFormatProvider? provider)
static short Parse(ReadOnlySpan< char > s, NumberStyles style, NumberFormatInfo info)
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, IFormatProvider? provider, out short result)
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out short result)
static bool TryParse(ReadOnlySpan< char > s, out short result)
int CompareTo(short value)
override int GetHashCode()
int CompareTo(object? value)
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, NumberFormatInfo info, out short result)
static short Parse(string s, NumberStyles style, IFormatProvider? provider)
string ToString(string? format, IFormatProvider? provider)
static short Parse(string s, NumberStyles style)
static bool TryParse([NotNullWhen(true)] string? s, out short result)
override string ToString()
static short Parse(string s, IFormatProvider? provider)
static short short Remainder INumber< short >. DivRem(short left, short right)
static short Parse(ReadOnlySpan< char > s, NumberStyles style=NumberStyles.Integer, IFormatProvider? provider=null)
override bool Equals([NotNullWhen(true)] object? obj)
string ToString(string? format)
bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >), IFormatProvider? provider=null)
string ToString(IFormatProvider? provider)
static short Parse(string s)