本文整理匯總了C#中System.SByte.MaxValue字段的典型用法代碼示例。如果您正苦於以下問題:C# SByte.MaxValue字段的具體用法?C# SByte.MaxValue怎麽用?C# SByte.MaxValue使用的例子?那麽, 這裏精選的字段代碼示例或許可以為您提供幫助。
在下文中一共展示了SByte.MaxValue字段的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: if
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);
}
示例2: Main
//引入命名空間
using System;
using System.Data;
class Class1{
static void Main(string[] args){
uint x = 0x01001001;
uint XComp = ~x;
Console.WriteLine("~x = " + ~x);
sbyte B1 = sbyte.MinValue;
sbyte B2 = sbyte.MaxValue;
Console.WriteLine("B1|B2 = " + (((byte)B1|(byte)B2)));
ushort x2 = 0x00000001; // Problem
Console.WriteLine("~x2 = " + ~x2);
byte y = 1; // Problem
//byte B = ~y;
Console.WriteLine("~y = " + ~y);
char x3 = (char)1; // Problem
Console.WriteLine("~x3 = " + ~x3);
sbyte x5 = 1;
Console.WriteLine("~x5 = " + ~x5);
uint IntResult = (uint)~x;
Console.WriteLine("IntResult = " + IntResult);
byte ByteResult = (byte)~y;
Console.WriteLine("ByteResult = " + ByteResult);
}
}