本文整理汇总了C#中System.Stream.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadByte方法的具体用法?C# Stream.ReadByte怎么用?C# Stream.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Stream
的用法示例。
在下文中一共展示了Stream.ReadByte方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadByte
public static byte ReadByte(Stream s)
{
int v = s.ReadByte();
if (v == -1)
throw new Exception("IOException: EOF");
return (byte)v;
}
示例2: InternalReadByte
public static int InternalReadByte(Stream s)
{
int v = s.ReadByte();
if (v == -1)
throw new Exception("IOException: EOF");
return v;
}
示例3: ReadUInt32
public static uint ReadUInt32(Stream s)
{
int a = s.ReadByte();
int b = s.ReadByte();
int c = s.ReadByte();
int d = InternalReadByte(s);
return (uint)((a << 24) | (b << 16) | (c << 8) | d);
}
示例4: ReadUInt16
public static ushort ReadUInt16(Stream s)
{
int a = s.ReadByte();
int b = InternalReadByte(s);
return (ushort)((a << 8) | b);
}
示例5: ReadChar
public static char ReadChar(Stream s)
{
int a = s.ReadByte();
int b = InternalReadByte(s);
return (char)((a << 8) | b);
}
示例6: ReadSByte
public static sbyte ReadSByte(Stream s)
{
int v = s.ReadByte();
return (sbyte)v;
}
示例7: InternalReadInt16
private static int InternalReadInt16(Stream s)
{
int a = s.ReadByte();
int b = InternalReadByte(s);
return ((a << 8) | b);
}
示例8: ReadUtfChar
private static int ReadUtfChar(Stream s, StringBuilder sb)
{
int a = InternalReadByte(s);
if ((a & 0x80) == 0)
{
sb.Append((char)a);
return 1;
}
if ((a & 0xe0) == 0xb0)
{
int b = InternalReadByte(s);
sb.Append((char)(((a & 0x1F) << 6) | (b & 0x3F)));
return 2;
}
if ((a & 0xf0) == 0xe0)
{
int b = s.ReadByte();
int c = InternalReadByte(s);
sb.Append((char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F)));
return 3;
}
throw new Exception("IOException: UTFDataFormat:");
}