SByte 结构
定义
表示 8 位有符号整数。Represents an 8-bit signed integer.
public value class SByte : IComparable, IComparable<System::SByte>, IConvertible, IEquatable<System::SByte>, IFormattable
public value class SByte : IComparable, IConvertible, IFormattable
public value class SByte : IComparable, IComparable<System::SByte>, IEquatable<System::SByte>, IFormattable
[System.CLSCompliant(false)]
public struct SByte : IComparable, IComparable<sbyte>, IConvertible, IEquatable<sbyte>, IFormattable
[System.CLSCompliant(false)]
[System.Serializable]
public struct SByte : IComparable, IConvertible, IFormattable
[System.CLSCompliant(false)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct SByte : IComparable, IComparable<sbyte>, IConvertible, IEquatable<sbyte>, IFormattable
[System.CLSCompliant(false)]
public struct SByte : IComparable, IComparable<sbyte>, IEquatable<sbyte>, IFormattable
[<System.CLSCompliant(false)>]
type sbyte = struct
interface IConvertible
interface IFormattable
[<System.CLSCompliant(false)>]
[<System.Serializable>]
type sbyte = struct
interface IFormattable
interface IConvertible
[<System.CLSCompliant(false)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type sbyte = struct
interface IFormattable
interface IConvertible
[<System.CLSCompliant(false)>]
type sbyte = struct
interface IFormattable
Public Structure SByte
Implements IComparable, IComparable(Of SByte), IConvertible, IEquatable(Of SByte), IFormattable
Public Structure SByte
Implements IComparable, IConvertible, IFormattable
Public Structure SByte
Implements IComparable, IComparable(Of SByte), IEquatable(Of SByte), IFormattable
- 继承
- 属性
- 实现
注解
SByte值类型表示其值范围从负128到正127的整数。The SByte value type represents integers with values ranging from negative 128 to positive 127.
重要
SByte类型不符合 CLS。The SByte type is not CLS-compliant. 符合 CLS 的替代类型为 Int16 。The CLS-compliant alternative type is Int16. Byte 可以改为使用来替换介于 SByte 零到之间的正值 MaxValue 。Byte can be used instead to replace a positive SByte value that ranges from zero to MaxValue. 有关 CLS 遵从性的详细信息,请参阅 语言独立性和 Language-Independent 组件。For more information about CLS compliance, see Language Independence and Language-Independent Components.
SByte 提供一些方法,用于比较此类型的实例,将实例的值转换为其字符串表示形式,并将数字的字符串表示形式转换为此类型的实例。SByte provides methods to compare instances of this type, convert the value of an instance to its string representation, and convert the string representation of a number to an instance of this type.
有关格式规范代码如何控制值类型的字符串表示形式的信息,请参阅 格式设置类型。For information about how format specification codes control the string representation of value types, see Formatting Types.
字段
MaxValue |
表示 SByte 的最大可能值。Represents the largest possible value of SByte. 此字段为常数。This field is constant. |
MinValue |
表示 SByte 的最小可能值。Represents the smallest possible value of SByte. 此字段为常数。This field is constant. |
方法
CompareTo(Object) |
将此实例与指定对象进行比较并返回一个对二者的相对值的指示。Compares this instance to a specified object and returns an indication of their relative values. |
CompareTo(SByte) |
将此实例与指定的 8 位有符号整数进行比较并返回对其相对值的指示。Compares this instance to a specified 8-bit signed integer and returns an indication of their relative values. |
Equals(Object) |
返回一个值,该值指示此实例是否等于指定的对象。Returns a value indicating whether this instance is equal to a specified object. |
Equals(SByte) |
返回一个值,该值指示此实例是否等于指定的 SByte 值。Returns a value indicating whether this instance is equal to a specified SByte value. |
GetHashCode() |
返回此实例的哈希代码。Returns the hash code for this instance. |
GetTypeCode() |
返回值类型 TypeCode 的 SByte。Returns the TypeCode for value type SByte. |
Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) |
将指定样式和区域性特定格式的数字的范围表示形式转换为它的等效 8 位带符号数值。Converts the span representation of a number that is in a specified style and culture-specific format to its 8-bit signed equivalent. |
Parse(String) |
将数字的字符串表示形式转换为它的等效 8 位有符号整数。Converts the string representation of a number to its 8-bit signed integer equivalent. |
Parse(String, IFormatProvider) |
将指定的区域性特定格式的数字的字符串表示形式转换为它的等效 8 位有符号整数。Converts the string representation of a number in a specified culture-specific format to its 8-bit signed integer equivalent. |
Parse(String, NumberStyles) |
将指定样式的数字的字符串表示形式转换为它的等效 8 位有符号整数。Converts the string representation of a number in a specified style to its 8-bit signed integer equivalent. |
Parse(String, NumberStyles, IFormatProvider) |
将指定样式和区域性特定格式的数字的字符串表示形式转换为它的等效 8 位有符号数值。Converts the string representation of a number that is in a specified style and culture-specific format to its 8-bit signed equivalent. |
ToString() |
将此实例的数值转换为其等效的字符串表示形式。Converts the numeric value of this instance to its equivalent string representation. |
ToString(IFormatProvider) |
使用指定的区域性特定格式信息,将此实例的数值转换为它的等效字符串表示形式。Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. |
ToString(String) |
使用指定的格式,将此实例的数值转换为它的等效字符串表示形式。Converts the numeric value of this instance to its equivalent string representation, using the specified format. |
ToString(String, IFormatProvider) |
使用指定的格式和区域性特定格式信息,将此实例的数值转换为它的等效字符串表示形式。Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information. |
TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) |
尝试将当前 8 位带符号整数实例的值的格式设置为提供的字符范围。Tries to format the value of the current 8-bit signed integer instance into the provided span of characters. |
TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, SByte) |
尝试将指定样式和区域性特定格式的数字的范围表示形式转换为其 SByte 等效项,并返回一个指示转换是否成功的值。Tries to convert the span representation of a number in a specified style and culture-specific format to its SByte equivalent, and returns a value that indicates whether the conversion succeeded. |
TryParse(ReadOnlySpan<Char>, SByte) |
尝试将数字的范围表示形式转换为它的等效 SByte,并返回一个指示转换是否成功的值。Tries to convert the span representation of a number to its SByte equivalent, and returns a value that indicates whether the conversion succeeded. |
TryParse(String, NumberStyles, IFormatProvider, SByte) |
尝试将指定样式和区域性特定格式的数字的字符串表示形式转换为其 SByte 等效项,并返回一个指示转换是否成功的值。Tries to convert the string representation of a number in a specified style and culture-specific format to its SByte equivalent, and returns a value that indicates whether the conversion succeeded. |
TryParse(String, SByte) |
尝试将数字的字符串表示形式转换为它的等效 SByte,并返回一个指示转换是否成功的值。Tries to convert the string representation of a number to its SByte equivalent, and returns a value that indicates whether the conversion succeeded. |
显式接口实现
适用于
线程安全性
此类型的所有成员都是线程安全的。All members of this type are thread safe. 看似修改实例状态的成员实际上返回用新值初始化的新实例。Members that appear to modify instance state actually return a new instance initialized with the new value. 与任何其他类型一样,读取和写入包含此类型的实例的共享变量时,必须通过锁保护以保证线程安全。As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.