本文整理汇总了C#中BinarySerializer.GetByte方法的典型用法代码示例。如果您正苦于以下问题:C# BinarySerializer.GetByte方法的具体用法?C# BinarySerializer.GetByte怎么用?C# BinarySerializer.GetByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinarySerializer
的用法示例。
在下文中一共展示了BinarySerializer.GetByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServerWelcome
/// <summary>
/// Parsuje wiadomość.
/// </summary>
/// <param name="msg">Wiadomość.</param>
public ServerWelcome(Message msg)
{
if (msg.Type != MessageType.Welcome)
{
throw new InvalidCastException("Cannot convert this message to WelcomeMessage");
}
BinarySerializer s = new BinarySerializer(msg.Data);
this.ServerVersion = s.GetVersion();
byte flags = s.GetByte();
this.GameName = s.GetString();
}
示例2: Deserialization
public void Deserialization()
{
var serializer = new BinarySerializer(DataSerialized);
Assert.AreEqual(true, serializer.GetBool());
Assert.AreEqual((byte)0, serializer.GetByte());
Assert.AreEqual((byte)1, serializer.GetByte());
Assert.AreEqual('b', serializer.GetChar());
Assert.AreEqual((byte)0, serializer.GetByte());
Assert.AreEqual(1d, serializer.GetDouble());
Assert.AreEqual(1d, serializer.GetDouble());
Assert.AreEqual((short)-5, serializer.GetInt16());
Assert.AreEqual(-6, serializer.GetInt32());
Assert.AreEqual(7L, serializer.GetInt64());
Assert.AreEqual((sbyte)-2, serializer.GetSByte());
Assert.AreEqual(1f, serializer.GetFloat());
Assert.AreEqual((ushort)9, serializer.GetUInt16());
Assert.AreEqual(10U, serializer.GetUInt32());
Assert.AreEqual(11UL, serializer.GetUInt64());
Assert.AreEqual(new Version(1, 2, 3, 4), serializer.GetVersion());
}