本文整理汇总了C#中System.Byte.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Byte.GetType方法的具体用法?C# Byte.GetType怎么用?C# Byte.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Byte
的用法示例。
在下文中一共展示了Byte.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public bool PosTest1(int id, string curValue, Byte expValue, int fromBase)
{
bool retVal = true;
Byte newValue;
IFormatProvider myfp;
TestLibrary.TestFramework.BeginScenario("PosTest"+id+": Convert.ToByte(...) (curValue:string " +curValue+" newType:"+expValue.GetType()+")");
try
{
newValue = Convert.ToByte(curValue, fromBase);
if (!newValue.Equals(expValue))
{
TestLibrary.TestFramework.LogError("000", "Value mismatch: Expected(" + expValue + ") Actual(" +newValue + ")");
retVal = false;
}
if (10 == fromBase)
{
newValue = Convert.ToByte(curValue);
if (!newValue.Equals(expValue))
{
TestLibrary.TestFramework.LogError("001", "Value mismatch: Expected(" + expValue + ") Actual(" +newValue + ")");
retVal = false;
}
myfp = null;
newValue = Convert.ToByte(curValue, myfp);
if (!newValue.Equals(expValue))
{
TestLibrary.TestFramework.LogError("002", "Value mismatch: Expected(" + expValue + ") Actual(" +newValue + ")");
retVal = false;
}
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例2: SerializeBytesValueTest
public void SerializeBytesValueTest()
{
// Arrange
var value = new Byte[] {0x11, 0x22, 0x33};
ConstantExpression constant = Expression.Constant(value, value.GetType());
// Act
string result = constant.Serialize();
// Assert
Assert.NotNull(result);
var stringBuilder = new StringBuilder("X'");
foreach (byte num in value)
{
stringBuilder.AppendFormat("{0:x2}", num);
}
stringBuilder.Append("'");
Assert.Equal(result, stringBuilder.ToString());
}