本文整理汇总了C#中System.SByte.MinValue字段的典型用法代码示例。如果您正苦于以下问题:C# SByte.MinValue字段的具体用法?C# SByte.MinValue怎么用?C# SByte.MinValue使用的例子?那么恭喜您, 这里精选的字段代码示例或许可以为您提供帮助。
在下文中一共展示了SByte.MinValue字段的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);
}
}