10[TypeForwardedFrom(
"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
11public readonly
struct Byte :
IComparable,
IConvertible,
ISpanFormattable,
IFormattable,
IComparable<byte>,
IEquatable<byte>,
IBinaryInteger<byte>,
IBinaryNumber<byte>,
IBitwiseOperators<byte, byte, byte>,
INumber<byte>,
IAdditionOperators<byte, byte, byte>,
IAdditiveIdentity<byte, byte>,
IComparisonOperators<byte, byte>,
IEqualityOperators<byte, byte>,
IDecrementOperators<byte>,
IDivisionOperators<byte, byte, byte>,
IIncrementOperators<byte>,
IModulusOperators<byte, byte, byte>,
IMultiplicativeIdentity<byte, byte>,
IMultiplyOperators<byte, byte, byte>,
ISpanParseable<byte>,
IParseable<byte>,
ISubtractionOperators<byte, byte, byte>,
IUnaryNegationOperators<byte, byte>,
IUnaryPlusOperators<byte, byte>,
IShiftOperators<byte, byte>,
IMinMaxValue<byte>,
IUnsignedNumber<byte>
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")]
47 return this - (byte)
value;
55 public override bool Equals([NotNullWhen(
true)]
object?
obj)
61 return this == (byte)
obj;
123 if (parsingStatus != 0)
134 public static bool TryParse([NotNullWhen(
true)]
string?
s, out
byte result)
173 result = (byte)result2;
282 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
285 return (
byte)(left + right);
288 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
294 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
300 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
303 return (
byte)((
value << (rotateAmount & 7)) | (
value >> ((8 - rotateAmount) & 7)));
306 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
309 return (
byte)((
value >> (rotateAmount & 7)) | (
value << ((8 - rotateAmount) & 7)));
312 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
318 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
324 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
330 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
333 return (
byte)(left & right);
336 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
339 return (
byte)(left | right);
342 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
345 return (
byte)(left ^ right);
348 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
351 return (
byte)(~value);
354 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
360 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
363 return left <= right;
366 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
372 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
375 return left >= right;
378 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
384 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
387 return (
byte)(left / right);
390 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
393 return left == right;
396 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
399 return left != right;
402 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
408 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
411 return (
byte)(left % right);
414 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
417 return (
byte)(left * right);
420 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
426 [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")]
436 if (typeof(TOther) == typeof(
byte))
438 return (
byte)(object)
value;
442 if (typeof(TOther) == typeof(
char))
444 return (
byte)(char)(
object)
value;
446 if (typeof(TOther) == typeof(decimal))
448 return (
byte)(decimal)(
object)
value;
450 if (typeof(TOther) == typeof(
double))
452 return (
byte)(double)(
object)
value;
454 if (typeof(TOther) == typeof(
short))
458 if (typeof(TOther) == typeof(
int))
460 return (
byte)(int)(
object)
value;
462 if (typeof(TOther) == typeof(
long))
464 return (
byte)(long)(
object)
value;
466 if (typeof(TOther) == typeof(
IntPtr))
470 if (typeof(TOther) == typeof(sbyte))
472 return (
byte)(sbyte)(
object)
value;
474 if (typeof(TOther) == typeof(
float))
476 return (
byte)(float)(
object)
value;
478 if (typeof(TOther) == typeof(ushort))
480 return (
byte)(ushort)(
object)
value;
482 if (typeof(TOther) == typeof(uint))
484 return (
byte)(uint)(
object)
value;
486 if (typeof(TOther) == typeof(ulong))
488 return (
byte)(ulong)(
object)
value;
490 if (typeof(TOther) == typeof(
UIntPtr))
500 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
503 if (typeof(TOther) == typeof(
byte))
505 return (
byte)(object)
value;
507 if (typeof(TOther) == typeof(
char))
509 char c = (char)(
object)
value;
514 return byte.MaxValue;
516 if (typeof(TOther) == typeof(decimal))
518 decimal num = (decimal)(
object)
value;
527 return byte.MaxValue;
529 if (typeof(TOther) == typeof(
double))
531 double num2 = (double)(
object)
value;
540 return byte.MaxValue;
542 if (typeof(TOther) == typeof(
short))
553 return byte.MaxValue;
555 if (typeof(TOther) == typeof(
int))
557 int num4 = (int)(
object)
value;
566 return byte.MaxValue;
568 if (typeof(TOther) == typeof(
long))
570 long num5 = (long)(
object)
value;
579 return byte.MaxValue;
581 if (typeof(TOther) == typeof(
IntPtr))
584 if ((nint)intPtr <= 255)
586 if ((nint)intPtr >= 0)
588 return (
byte)(nint)intPtr;
594 if (typeof(TOther) == typeof(sbyte))
596 sbyte b = (sbyte)(
object)
value;
603 if (typeof(TOther) == typeof(
float))
605 float num6 = (float)(
object)
value;
614 return byte.MaxValue;
616 if (typeof(TOther) == typeof(ushort))
618 ushort num7 = (ushort)(
object)
value;
623 return byte.MaxValue;
625 if (typeof(TOther) == typeof(uint))
627 uint num8 = (uint)(
object)
value;
632 return byte.MaxValue;
634 if (typeof(TOther) == typeof(ulong))
636 ulong num9 = (ulong)(
object)
value;
641 return byte.MaxValue;
643 if (typeof(TOther) == typeof(
UIntPtr))
646 if ((nuint)uIntPtr <= 255)
648 return (
byte)(nuint)uIntPtr;
657 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
660 if (typeof(TOther) == typeof(
byte))
662 return (
byte)(object)
value;
664 if (typeof(TOther) == typeof(
char))
666 return (
byte)(char)(
object)
value;
668 if (typeof(TOther) == typeof(decimal))
670 return (
byte)(decimal)(
object)
value;
672 if (typeof(TOther) == typeof(
double))
674 return (
byte)(double)(
object)
value;
676 if (typeof(TOther) == typeof(
short))
680 if (typeof(TOther) == typeof(
int))
682 return (
byte)(int)(
object)
value;
684 if (typeof(TOther) == typeof(
long))
686 return (
byte)(long)(
object)
value;
688 if (typeof(TOther) == typeof(
IntPtr))
692 if (typeof(TOther) == typeof(sbyte))
694 return (
byte)(sbyte)(
object)
value;
696 if (typeof(TOther) == typeof(
float))
698 return (
byte)(float)(
object)
value;
700 if (typeof(TOther) == typeof(ushort))
702 return (
byte)(ushort)(
object)
value;
704 if (typeof(TOther) == typeof(uint))
706 return (
byte)(uint)(
object)
value;
708 if (typeof(TOther) == typeof(ulong))
710 return (
byte)(ulong)(
object)
value;
712 if (typeof(TOther) == typeof(
UIntPtr))
720 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
726 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
732 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
738 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
741 return Parse(
s, style, provider);
744 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
747 return Parse(
s, style, provider);
750 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
753 return (
byte)((
value != 0) ? 1u : 0u);
757 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
760 if (typeof(TOther) == typeof(
byte))
762 result = (byte)(
object)
value;
765 if (typeof(TOther) == typeof(
char))
767 char c = (char)(
object)
value;
776 if (typeof(TOther) == typeof(decimal))
778 decimal num = (decimal)(
object)
value;
779 if (num < 0m || num > 255m)
787 if (typeof(TOther) == typeof(
double))
789 double num2 = (double)(
object)
value;
790 if (num2 < 0.0 || num2 > 255.0)
798 if (typeof(TOther) == typeof(
short))
801 if (num3 < 0 || num3 > 255)
809 if (typeof(TOther) == typeof(
int))
811 int num4 = (int)(
object)
value;
812 if (num4 < 0 || num4 > 255)
820 if (typeof(TOther) == typeof(
long))
822 long num5 = (long)(
object)
value;
823 if (num5 < 0 || num5 > 255)
831 if (typeof(TOther) == typeof(
IntPtr))
834 if ((nint)intPtr < 0 || (nint)intPtr > 255)
839 result = (byte)(nint)intPtr;
842 if (typeof(TOther) == typeof(sbyte))
844 sbyte b = (sbyte)(
object)
value;
853 if (typeof(TOther) == typeof(
float))
855 float num6 = (float)(
object)
value;
856 if (num6 < 0f || num6 > 255f)
864 if (typeof(TOther) == typeof(ushort))
866 ushort num7 = (ushort)(
object)
value;
875 if (typeof(TOther) == typeof(uint))
877 uint num8 = (uint)(
object)
value;
886 if (typeof(TOther) == typeof(ulong))
888 ulong num9 = (ulong)(
object)
value;
897 if (typeof(TOther) == typeof(
UIntPtr))
900 if ((nuint)uIntPtr > 255)
905 result = (byte)(nuint)uIntPtr;
913 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
916 return TryParse(
s, style, provider, out result);
919 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
922 return TryParse(
s, style, provider, out result);
925 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
928 return Parse(
s, provider);
931 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
937 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
940 return (
byte)(
value << shiftAmount);
943 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
946 return (
byte)(
value >> shiftAmount);
949 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
955 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
961 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
964 return (
byte)(left - right);
967 [RequiresPreviewFeatures(
"Generic Math is in preview.", Url =
"https://aka.ms/dotnet-warnings/generic-math-preview")]
970 return (
byte)(-
value);
973 [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 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 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 InvalidCast_FromTo
static string Format(string resourceFormat, object p1)
static string Arg_MustBeByte
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 bool TryParse([NotNullWhen(true)] string? s, out byte result)
string ToString(string? format)
static bool TryParse(ReadOnlySpan< char > s, out byte result)
static byte Parse(string s, NumberStyles style, IFormatProvider? provider)
bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >), IFormatProvider? provider=null)
static byte Parse(string s, IFormatProvider? provider)
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, IFormatProvider? provider, out byte result)
override bool Equals([NotNullWhen(true)] object? obj)
static byte byte Remainder INumber< byte >. DivRem(byte left, byte right)
string ToString(IFormatProvider? provider)
static byte Parse(ReadOnlySpan< char > s, NumberStyles style, NumberFormatInfo info)
static byte Parse(string s)
string ToString(string? format, IFormatProvider? provider)
override int GetHashCode()
static byte Parse(string s, NumberStyles style)
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, NumberFormatInfo info, out byte result)
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out byte result)
int CompareTo(byte value)
static byte Parse(ReadOnlySpan< char > s, NumberStyles style=NumberStyles.Integer, IFormatProvider? provider=null)
int CompareTo(object? value)
override string ToString()