11[TypeForwardedFrom(
"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
12public readonly
struct UInt16 :
IComparable,
IConvertible,
ISpanFormattable,
IFormattable,
IComparable<ushort>,
IEquatable<ushort>,
IBinaryInteger<ushort>,
IBinaryNumber<ushort>,
IBitwiseOperators<ushort, ushort, ushort>,
INumber<ushort>,
IAdditionOperators<ushort, ushort, ushort>,
IAdditiveIdentity<ushort, ushort>,
IComparisonOperators<ushort, ushort>,
IEqualityOperators<ushort, ushort>,
IDecrementOperators<ushort>,
IDivisionOperators<ushort, ushort, ushort>,
IIncrementOperators<ushort>,
IModulusOperators<ushort, ushort, ushort>,
IMultiplicativeIdentity<ushort, ushort>,
IMultiplyOperators<ushort, ushort, ushort>,
ISpanParseable<ushort>,
IParseable<ushort>,
ISubtractionOperators<ushort, ushort, ushort>,
IUnaryNegationOperators<ushort, ushort>,
IUnaryPlusOperators<ushort, ushort>,
IShiftOperators<ushort, ushort>,
IMinMaxValue<ushort>,
IUnsignedNumber<ushort>
20 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
23 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
26 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
29 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
32 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
35 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
46 return this - (ushort)
value;
56 public override bool Equals([NotNullWhen(
true)]
object?
obj)
62 return this == (ushort)
obj;
149 if (parsingStatus != 0)
157 return (ushort)result;
160 public static bool TryParse([NotNullWhen(
true)]
string?
s, out ushort result)
199 result = (ushort)result2;
283 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
286 return (ushort)(left + right);
289 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
295 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
301 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
304 return (ushort)((
value << (rotateAmount & 0xF)) | (
value >> ((16 - rotateAmount) & 0xF)));
307 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
310 return (ushort)((
value >> (rotateAmount & 0xF)) | (
value << ((16 - rotateAmount) & 0xF)));
313 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
319 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
325 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
331 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
334 return (ushort)(left & right);
337 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
340 return (ushort)(left | right);
343 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
346 return (ushort)(left ^ right);
349 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
352 return (ushort)(~value);
355 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
361 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
364 return left <= right;
367 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
373 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
376 return left >= right;
379 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
385 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
388 return (ushort)(left / right);
391 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
394 return 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")]
409 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
412 return (ushort)(left % right);
415 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
418 return (ushort)(left * right);
421 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
427 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
434 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
437 if (typeof(TOther) == typeof(
byte))
439 return (
byte)(object)
value;
441 if (typeof(TOther) == typeof(
char))
443 return (
char)(object)
value;
445 if (typeof(TOther) == typeof(decimal))
447 return (ushort)(decimal)(
object)
value;
451 if (typeof(TOther) == typeof(
double))
453 return (ushort)(double)(
object)
value;
455 if (typeof(TOther) == typeof(
short))
459 if (typeof(TOther) == typeof(
int))
461 return (ushort)(int)(
object)
value;
463 if (typeof(TOther) == typeof(
long))
465 return (ushort)(long)(
object)
value;
467 if (typeof(TOther) == typeof(
IntPtr))
471 if (typeof(TOther) == typeof(sbyte))
473 return (ushort)(sbyte)(
object)
value;
475 if (typeof(TOther) == typeof(
float))
477 return (ushort)(float)(
object)
value;
479 if (typeof(TOther) == typeof(ushort))
481 return (ushort)(object)
value;
483 if (typeof(TOther) == typeof(uint))
485 return (ushort)(uint)(
object)
value;
487 if (typeof(TOther) == typeof(ulong))
489 return (ushort)(ulong)(
object)
value;
491 if (typeof(TOther) == typeof(
UIntPtr))
501 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
504 if (typeof(TOther) == typeof(
byte))
506 return (
byte)(object)
value;
508 if (typeof(TOther) == typeof(
char))
510 return (
char)(object)
value;
512 if (typeof(TOther) == typeof(decimal))
514 decimal num = (decimal)(
object)
value;
523 return ushort.MaxValue;
525 if (typeof(TOther) == typeof(
double))
527 double num2 = (double)(
object)
value;
528 if (!(num2 > 65535.0))
536 return ushort.MaxValue;
538 if (typeof(TOther) == typeof(
short))
547 if (typeof(TOther) == typeof(
int))
549 int num4 = (int)(
object)
value;
558 return ushort.MaxValue;
560 if (typeof(TOther) == typeof(
long))
562 long num5 = (long)(
object)
value;
571 return ushort.MaxValue;
573 if (typeof(TOther) == typeof(
IntPtr))
576 if ((nint)intPtr <= 65535)
578 if ((nint)intPtr >= 0)
580 return (ushort)(nint)intPtr;
586 if (typeof(TOther) == typeof(sbyte))
588 sbyte b = (sbyte)(
object)
value;
595 if (typeof(TOther) == typeof(
float))
597 float num6 = (float)(
object)
value;
598 if (!(num6 > 65535f))
606 return ushort.MaxValue;
608 if (typeof(TOther) == typeof(ushort))
610 return (ushort)(object)
value;
612 if (typeof(TOther) == typeof(uint))
614 uint num7 = (uint)(
object)
value;
619 return ushort.MaxValue;
621 if (typeof(TOther) == typeof(ulong))
623 ulong num8 = (ulong)(
object)
value;
628 return ushort.MaxValue;
630 if (typeof(TOther) == typeof(
UIntPtr))
633 if ((nuint)uIntPtr <= 65535)
635 return (ushort)(nuint)uIntPtr;
644 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
647 if (typeof(TOther) == typeof(
byte))
649 return (
byte)(object)
value;
651 if (typeof(TOther) == typeof(
char))
653 return (
char)(object)
value;
655 if (typeof(TOther) == typeof(decimal))
657 return (ushort)(decimal)(
object)
value;
659 if (typeof(TOther) == typeof(
double))
661 return (ushort)(double)(
object)
value;
663 if (typeof(TOther) == typeof(
short))
667 if (typeof(TOther) == typeof(
int))
669 return (ushort)(int)(
object)
value;
671 if (typeof(TOther) == typeof(
long))
673 return (ushort)(long)(
object)
value;
675 if (typeof(TOther) == typeof(
IntPtr))
679 if (typeof(TOther) == typeof(sbyte))
681 return (ushort)(sbyte)(
object)
value;
683 if (typeof(TOther) == typeof(
float))
685 return (ushort)(float)(
object)
value;
687 if (typeof(TOther) == typeof(ushort))
689 return (ushort)(object)
value;
691 if (typeof(TOther) == typeof(uint))
693 return (ushort)(uint)(
object)
value;
695 if (typeof(TOther) == typeof(ulong))
697 return (ushort)(ulong)(
object)
value;
699 if (typeof(TOther) == typeof(
UIntPtr))
707 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
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")]
728 return Parse(
s, style, provider);
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 (ushort)((
value != 0) ? 1u : 0u);
744 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
747 if (typeof(TOther) == typeof(
byte))
749 result = (byte)(
object)
value;
752 if (typeof(TOther) == typeof(
char))
754 result = (char)(
object)
value;
757 if (typeof(TOther) == typeof(decimal))
759 decimal num = (decimal)(
object)
value;
760 if (num < 0m || num > 65535m)
765 result = (ushort)num;
768 if (typeof(TOther) == typeof(
double))
770 double num2 = (double)(
object)
value;
771 if (num2 < 0.0 || num2 > 65535.0)
776 result = (ushort)num2;
779 if (typeof(TOther) == typeof(
short))
787 result = (ushort)num3;
790 if (typeof(TOther) == typeof(
int))
792 int num4 = (int)(
object)
value;
793 if (num4 < 0 || num4 > 65535)
798 result = (ushort)num4;
801 if (typeof(TOther) == typeof(
long))
803 long num5 = (long)(
object)
value;
804 if (num5 < 0 || num5 > 65535)
809 result = (ushort)num5;
812 if (typeof(TOther) == typeof(
IntPtr))
815 if ((nint)intPtr < 0 || (nint)intPtr > 65535)
820 result = (ushort)(nint)intPtr;
823 if (typeof(TOther) == typeof(sbyte))
825 sbyte b = (sbyte)(
object)
value;
834 if (typeof(TOther) == typeof(
float))
836 float num6 = (float)(
object)
value;
837 if (num6 < 0f || num6 > 65535f)
842 result = (ushort)num6;
845 if (typeof(TOther) == typeof(ushort))
847 result = (ushort)(
object)
value;
850 if (typeof(TOther) == typeof(uint))
852 uint num7 = (uint)(
object)
value;
858 result = (ushort)num7;
861 if (typeof(TOther) == typeof(ulong))
863 ulong num8 = (ulong)(
object)
value;
869 result = (ushort)num8;
872 if (typeof(TOther) == typeof(
UIntPtr))
875 if ((nuint)uIntPtr > 65535)
880 result = (ushort)(nuint)uIntPtr;
888 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
891 return TryParse(
s, style, provider, out result);
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 Parse(
s, provider);
906 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
912 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
915 return (ushort)(
value << shiftAmount);
918 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
921 return (ushort)(
value >> shiftAmount);
924 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
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")]
939 return (ushort)(left - right);
942 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
945 return (ushort)(-
value);
948 [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 short ToInt16(object? value)
static byte ToByte(object? value)
static uint ToUInt32(object? value)
static ulong ToUInt64(object? value)
static char ToChar(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 int DivRem(int a, int b, out int result)
static byte Max(byte val1, byte val2)
static void ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type=TypeCode.Empty)
static void ThrowOverflowException(TypeCode type)
static string FormatUInt32(uint value, string format, IFormatProvider provider)
static bool TryFormatUInt32(uint value, ReadOnlySpan< char > format, IFormatProvider provider, Span< char > destination, out int charsWritten)
static ParsingStatus TryParseUInt32(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info, out uint result)
static unsafe string UInt32ToDecStr(uint value)
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_MustBeUInt16
static string InvalidCast_FromTo
static string Format(string resourceFormat, object p1)
static void ThrowNotSupportedException(ExceptionResource resource)
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 ushort Parse(string s, NumberStyles style, IFormatProvider? provider)
static bool TryParse(ReadOnlySpan< char > s, out ushort result)
override bool Equals([NotNullWhen(true)] object? obj)
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, IFormatProvider? provider, out ushort result)
static ushort ushort Remainder INumber< ushort >. DivRem(ushort left, ushort right)
static ushort Parse(string s, IFormatProvider? provider)
int CompareTo(object? value)
override string ToString()
string ToString(string? format, IFormatProvider? provider)
override int GetHashCode()
static bool TryParse([NotNullWhen(true)] string? s, out ushort result)
static ushort Parse(string s, NumberStyles style)
bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >), IFormatProvider? provider=null)
static ushort Parse(string s)
string ToString(string? format)
static ushort Parse(ReadOnlySpan< char > s, NumberStyles style, NumberFormatInfo info)
static ushort Parse(ReadOnlySpan< char > s, NumberStyles style=NumberStyles.Integer, IFormatProvider? provider=null)
int CompareTo(ushort value)
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, NumberFormatInfo info, out ushort result)
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out ushort result)
string ToString(IFormatProvider? provider)