SByte.MaxValue Alan
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
mümkün olan en büyük değerini SBytetemsil eder. Bu alan sabittir.
public: System::SByte MaxValue = 127;
public const sbyte MaxValue = 127;
val mutable MaxValue : sbyte
Public Const MaxValue As SByte = 127
Value = 127
Aşağıdaki örnek, bir değerin MinValue tür dönüştürmesi gerçekleştirmeden önce türün SByte aralığında olduğunu doğrulamak için ve MaxValue alanlarını Int64 kullanır. Bu doğrulama, çalışma zamanında öğesini OverflowException engeller.
long longValue = -130;
sbyte byteValue;
if (longValue <= sbyte.MaxValue &&
longValue >= sbyte.MinValue)
{
byteValue = (sbyte) longValue;
Console.WriteLine("Converted long integer value to {0}.", byteValue);
}
else
{
sbyte rangeLimit;
string relationship;
if (longValue > sbyte.MaxValue)
{
rangeLimit = sbyte.MaxValue;
relationship = "greater";
}
else
{
rangeLimit = sbyte.MinValue;
relationship = "less";
}
Console.WriteLine("Conversion failure: {0:n0} is {1} than {2}.",
longValue,
relationship,
rangeLimit);
}
let longValue = -130L
if longValue <= int64 SByte.MaxValue && longValue >= int64 SByte.MinValue then
let byteValue = int8 longValue
printfn $"Converted long integer value to {byteValue}."
else
let rangeLimit, relationship =
if longValue > int64 SByte.MaxValue then
SByte.MaxValue, "greater"
else
SByte.MinValue, "less"
printfn $"Conversion failure: {longValue:n0} is {relationship} than {rangeLimit}."
Dim longValue As Long = -130
Dim byteValue As SByte
If longValue <= SByte.MaxValue AndAlso _
longValue >= SByte.MinValue Then
byteValue = CSByte(longValue)
Console.WriteLine("Converted long integer value to {0}.", byteValue)
Else
Dim rangeLimit As SByte
Dim relationship As String
If longValue > SByte.MaxValue Then
rangeLimit = SByte.MaxValue
relationship = "greater"
Else
rangeLimit = SByte.MinValue
relationship = "less"
End If
Console.WriteLine("Conversion failure: {0:n0} is {1} than {2}.", _
longValue, _
relationship, _
rangeLimit)
End If
Bu sabitin değeri 127'dir; yani onaltılık 0x7F.
Ürün | Sürümler |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET geri bildirimi
.NET, açık kaynak bir projedir. Geri bildirim sağlamak için bir bağlantı seçin: