IBinaryInteger<TSelf> 接口

定义

定义以 base-2 格式表示的整数类型。

C#
public interface IBinaryInteger<TSelf> : IComparable<TSelf>, IEquatable<TSelf>, IParsable<TSelf>, ISpanParsable<TSelf>, System.Numerics.IAdditionOperators<TSelf,TSelf,TSelf>, System.Numerics.IAdditiveIdentity<TSelf,TSelf>, System.Numerics.IBinaryNumber<TSelf>, System.Numerics.IBitwiseOperators<TSelf,TSelf,TSelf>, System.Numerics.IComparisonOperators<TSelf,TSelf,bool>, System.Numerics.IDecrementOperators<TSelf>, System.Numerics.IDivisionOperators<TSelf,TSelf,TSelf>, System.Numerics.IEqualityOperators<TSelf,TSelf,bool>, System.Numerics.IIncrementOperators<TSelf>, System.Numerics.IModulusOperators<TSelf,TSelf,TSelf>, System.Numerics.IMultiplicativeIdentity<TSelf,TSelf>, System.Numerics.IMultiplyOperators<TSelf,TSelf,TSelf>, System.Numerics.INumber<TSelf>, System.Numerics.INumberBase<TSelf>, System.Numerics.IShiftOperators<TSelf,int,TSelf>, System.Numerics.ISubtractionOperators<TSelf,TSelf,TSelf>, System.Numerics.IUnaryNegationOperators<TSelf,TSelf>, System.Numerics.IUnaryPlusOperators<TSelf,TSelf> where TSelf : IBinaryInteger<TSelf>
C#
public interface IBinaryInteger<TSelf> : IComparable<TSelf>, IEquatable<TSelf>, IParsable<TSelf>, ISpanParsable<TSelf>, IUtf8SpanParsable<TSelf>, System.Numerics.IAdditionOperators<TSelf,TSelf,TSelf>, System.Numerics.IAdditiveIdentity<TSelf,TSelf>, System.Numerics.IBinaryNumber<TSelf>, System.Numerics.IBitwiseOperators<TSelf,TSelf,TSelf>, System.Numerics.IComparisonOperators<TSelf,TSelf,bool>, System.Numerics.IDecrementOperators<TSelf>, System.Numerics.IDivisionOperators<TSelf,TSelf,TSelf>, System.Numerics.IEqualityOperators<TSelf,TSelf,bool>, System.Numerics.IIncrementOperators<TSelf>, System.Numerics.IModulusOperators<TSelf,TSelf,TSelf>, System.Numerics.IMultiplicativeIdentity<TSelf,TSelf>, System.Numerics.IMultiplyOperators<TSelf,TSelf,TSelf>, System.Numerics.INumber<TSelf>, System.Numerics.INumberBase<TSelf>, System.Numerics.IShiftOperators<TSelf,int,TSelf>, System.Numerics.ISubtractionOperators<TSelf,TSelf,TSelf>, System.Numerics.IUnaryNegationOperators<TSelf,TSelf>, System.Numerics.IUnaryPlusOperators<TSelf,TSelf> where TSelf : IBinaryInteger<TSelf>

类型参数

TSelf

实现接口的类型。

派生
实现

方法

CompareTo(Object)

将当前实例与同一类型的另一个对象进行比较,并返回一个整数,该整数指示当前实例在排序顺序中是否与另一个对象位于同一位置。

(继承自 IComparable)
CompareTo(T)

将当前实例与同一类型的另一个对象进行比较,并返回一个整数,该整数指示当前实例在排序顺序中是否与另一个对象位于同一位置。

(继承自 IComparable<T>)
DivRem(TSelf, TSelf)

计算两个值的商和余数。

Equals(T)

指示当前对象是否等于同一类型的另一个对象。

(继承自 IEquatable<T>)
GetByteCount()

获取将作为 TryWriteLittleEndian(Span<Byte>, Int32)一部分写入的字节数。

GetShortestBitLength()

获取最短的两个当前值的补数表示形式的长度(以位为单位)。

LeadingZeroCount(TSelf)

计算值中的前导零位数。

PopCount(TSelf)

计算值中设置的位数。

ReadBigEndian(Byte[], Boolean)

从给定数组中读取一个二进制数(采用大端格式)并将其转换为当前类型的实例。

ReadBigEndian(Byte[], Int32, Boolean)

从给定数组中读取一个二进制数(采用大端格式)并将其转换为当前类型的实例。

ReadBigEndian(ReadOnlySpan<Byte>, Boolean)

从给定范围读取两个的补数(采用大端格式)并将其转换为当前类型的实例。

ReadLittleEndian(Byte[], Boolean)

从给定数组(以小端格式)读取两个的补数,并将其转换为当前类型的实例。

ReadLittleEndian(Byte[], Int32, Boolean)

从给定数组(以小端格式)读取两个的补数,并将其转换为当前类型的实例。

ReadLittleEndian(ReadOnlySpan<Byte>, Boolean)

从给定范围(以小端格式)读取两个的补数,并将其转换为当前类型的实例。

RotateLeft(TSelf, Int32)

按给定量旋转一个值。

RotateRight(TSelf, Int32)

按给定的量向右旋转值。

ToString(String, IFormatProvider)

使用指定格式设置当前实例的值的格式。

(继承自 IFormattable)
TrailingZeroCount(TSelf)

计算值中尾随零位的数目。

TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

尝试将当前实例的值格式化为 UTF-8,并将其设置为提供的字节范围。

(继承自 IUtf8SpanFormattable)
TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

尝试将当前实例的值格式化为提供的字符范围。

(继承自 ISpanFormattable)
TryReadBigEndian(ReadOnlySpan<Byte>, Boolean, TSelf)

尝试从范围(采用大端格式)读取两个的补数,并将其转换为当前类型的实例。

TryReadLittleEndian(ReadOnlySpan<Byte>, Boolean, TSelf)

尝试从范围读取两个的补数(采用小端格式)并将其转换为当前类型的实例。

TryWriteBigEndian(Span<Byte>, Int32)

尝试将当前值(采用 big-endian 格式)写入给定范围。

TryWriteLittleEndian(Span<Byte>, Int32)

尝试将当前值(以小端格式)写入给定范围。

WriteBigEndian(Byte[])

将当前值(采用 big-endian 格式)写入给定数组。

WriteBigEndian(Byte[], Int32)

将当前值(采用 big-endian 格式)写入给定数组。

WriteBigEndian(Span<Byte>)

将当前值(采用 big-endian 格式)写入给定范围。

WriteLittleEndian(Byte[])

将当前值(以小端格式)写入给定数组。

WriteLittleEndian(Byte[], Int32)

将当前值(以小尾格式)写入从指定索引开始的指定数组。

WriteLittleEndian(Span<Byte>)

将当前值(以小端格式)写入给定范围。

显式接口实现

IUtf8SpanFormattable.TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

尝试将当前实例的值格式化为 UTF-8,并将其设置为提供的字节范围。

(继承自 INumberBase<TSelf>)
IUtf8SpanParsable<TSelf>.Parse(ReadOnlySpan<Byte>, IFormatProvider)

将 UTF-8 字符的范围分析为值。

(继承自 INumberBase<TSelf>)
IUtf8SpanParsable<TSelf>.TryParse(ReadOnlySpan<Byte>, IFormatProvider, TSelf)

尝试将 UTF-8 字符的范围分析为值。

(继承自 INumberBase<TSelf>)

适用于

产品 版本
.NET 7, 8, 9