本文整理汇总了C#中System.SByte类的典型用法代码示例。如果您正苦于以下问题:C# SByte类的具体用法?C# SByte怎么用?C# SByte使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SByte类属于System命名空间,在下文中一共展示了SByte类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSByte
private static void TestSByte( SByte value )
{
var output = new MemoryStream();
Packer.Create( output ).Pack( value );
Assert.AreEqual( value, Unpacking.UnpackSByte( new MemoryStream( output.ToArray() ) ) );
Assert.AreEqual( value, Unpacking.UnpackSByte( output.ToArray() ).Value );
}
示例2: Test_SetDataTypesFromValue
private static void Test_SetDataTypesFromValue()
{
CUBRIDParameter param = new CUBRIDParameter();
param.ParameterName = "?p";
Boolean b = true;
param.Value = b;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT);
SByte sb = new SByte();
param.Value = sb;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT);
Byte by = new Byte();
param.Value = by;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT);
Int16 i16 = 0;
param.Value = i16;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT);
UInt16 ui16 = 0;
param.Value = ui16;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT);
UInt32 ui32 = 0;
param.Value = ui32;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_INT);
Int64 i64 = 0;
param.Value = i64;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_BIGINT);
UInt64 ui64 = 0;
param.Value = ui64;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_BIGINT);
param.Value = DateTime.Now;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_DATETIME);
string str = "cubrid";
param.Value = str;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_STRING);
Single sin = 0;
param.Value = sin;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_FLOAT);
Double dou = 0;
param.Value = dou;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_DOUBLE);
Decimal dec = 0;
param.Value = dec;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_NUMERIC);
DBNull n=null;
param.Value = n;
Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_NULL);
}
示例3: Serialize
public override SByte[] Serialize(String data)
{
if (String.IsNullOrEmpty(data))
return null;
var totalLength = buildHead(data.Length, data);
encodeData = new SByte[totalLength];
var startX = 0;
for (int i = 0; i < data.Length / 3; i++)
{
var value = Convert.ToString(Int32.Parse(data.Substring(startX, 3)), 2);
value = Converter.SupplyZero(10, value);
fillData(startX + headLength, value);
startX += 3;
}
startX /= 3;
var remainer = totalLength - startX * 10;
if (remainer > 0)
{
var value = Convert.ToString(Int32.Parse(data.Substring(startX)), 2);
value = Converter.SupplyZero(remainer, value);
fillData(startX + headLength, value);
}
return encodeData;
}
示例4: encBytes
public String encBytes(SByte[] barr)
{
StringBuilder licKey = new
StringBuilder();
for
(int
i = 0; i <= 15; i++)
{
SByte i1 = barr[i];
int
j = 0;
j |= i1 & 0xFF;
j %= 32;
if
(i > 0 && i % 4 == 0)
{
licKey.Append("-"
);
}
// licKey = licKey.Append(Convert.ToChar(validChars.Substring(j, 1)));
}
// String licKey = Base64Utils.base64Encode(hash);
return
licKey.ToString();
}
示例5: Deserialize_V0
public void Deserialize_V0(Stream stream, DataVersion version)
{
Byte[] buffer = new Byte[1];
stream.Read(buffer, 0, 1);
Value = (SByte)buffer[0];
}
示例6: ReadSByteArray
public static SByte[] ReadSByteArray(this ObjectReader reader)
{
var length = reader.ReadInt32();
SByte[] value = new SByte[length];
for(int i = 0; i < length; i++) value[i] = (SByte)reader.Stream.ReadByte();
return value;
}
示例7: ParseSByte_Test_1
public MFTestResults ParseSByte_Test_1()
{
Log.Comment("SByte MinValue = " + SByte.MinValue.ToString());
Log.Comment("SByte MaxValue = " + SByte.MaxValue.ToString());
String[] strArr = GetRandomStringArray(SByte.MaxValue, true);
SByte[] _sByte = new SByte[intArr.Length];
for (int i = 0; i < _sByte.Length; i++)
{
_sByte[i] = (SByte)intArr[i];
}
int counter = 0;
SByte temp = 0;
for (int i = 0; i < strArr.Length; i++)
{
try
{
temp = SByte.Parse(strArr[i]);
}
catch (Exception ex)
{
Log.Comment(i.ToString() + " Caught : " + ex.Message + " when SByte.Parse('" + strArr[i] + "')");
counter++;
}
if (temp != _sByte[i])
{
Log.Comment(i.ToString() + " Expecting " + _sByte[i] + " but got " + temp);
counter++;
}
}
return (counter == 0) ? MFTestResults.Pass : MFTestResults.Fail;
}
示例8: ToSByte
public static SByte ToSByte(string valueToParse, SByte defaultValue)
{
SByte returnValue;
if (!SByte.TryParse(valueToParse, out returnValue))
returnValue = defaultValue;
return returnValue;
}
示例9: WorkOnInstanceAndLocal
private void WorkOnInstanceAndLocal()
{
int localInt, i, j;
for ( i = 0; i < 100; i++ )
{
int index = randomNumGen.Next(0, ValueArraySize);
instanceInt_1 = ValueArray[index];
Thread.Sleep(index);
localInt = instanceInt_1;
for ( j = 0; j < ValueArraySize; j++ )
if ( ValueArray[j] == localInt )
break;
if (j == ValueArraySize )
throw new Exception("WorkOnInstanceAndLocal: Atomicity of Read/Write violated - " + localInt);
}
SByte localInt_1;
localInt_1 = 1 + 1;
if(localInt_1 != 2)
throw new Exception("Loc_7453fg! Major Error here");
localInt_1 = SByte.MaxValue + SByte.MinValue;
if(localInt_1 != -1)
throw new Exception("Loc_98745sg! Major Error here");
localInt_1 = 50 * 2;
if(localInt_1 != 100)
throw new Exception("Loc_3975sg! Major Error here, " + localInt_1);
localInt_1 = SByte.Parse("32");
if(localInt_1 != 32)
throw new Exception("Loc_975esg! Major Error here, " + localInt_1);
localInt_1 = SByte.MaxValue;
if(localInt_1.GetHashCode() != 32639)
throw new Exception("Loc_07245sg! Major Error here, " + localInt_1.GetHashCode());
if(localInt_1.ToString() != "127")
throw new Exception("Loc_834sgd! Major Error here, " + localInt_1.ToString());
}
示例10: GarminFitnessSByteRange
public GarminFitnessSByteRange(SByte value, SByte min, SByte max)
{
m_MinimumValue = Math.Min(min, max);
m_MaximumValue = Math.Max(min, max);
Value = value;
}
示例11: Init
public override void Init(MapMemberInfo mapMemberInfo)
{
if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo");
_nullValue = Convert.ToSByte(mapMemberInfo.NullValue);
base.Init(mapMemberInfo);
}
示例12: Abs
public static object Abs(SByte x) {
if (x < 0) {
if (x == SByte.MinValue) return -(Int16)SByte.MinValue;
else return (SByte)(-x);
} else {
return x;
}
}
示例13: TestSByte
private static void TestSByte( SByte value )
{
var output = new MemoryStream();
Packer.Create( output ).Pack( value );
var mpo = UnpackOne( output );
Assert.AreEqual( value, ( SByte )mpo );
Assert.AreEqual( value, mpo.AsSByte() );
}
示例14: TestCtor
public static void TestCtor()
{
SByte i = new SByte();
Assert.True(i == 0);
i = 41;
Assert.True(i == 41);
}
示例15: ScanResponseEventArgs
public ScanResponseEventArgs (SByte rssi, Byte packet_type, Byte[] sender, Byte address_type, Byte bond, Byte[] data)
{
this.rssi = rssi;
this.packet_type = packet_type;
this.sender = sender;
this.address_type = address_type;
this.bond = bond;
this.data = data;
}