本文整理汇总了C#中System.IO.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.ReadByte方法的具体用法?C# System.IO.ReadByte怎么用?C# System.IO.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO
的用法示例。
在下文中一共展示了System.IO.ReadByte方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadInt
private int ReadInt(IO.Stream stream)
{
int p1 = stream.ReadByte();
int p2 = stream.ReadByte();
int p3 = stream.ReadByte();
int p4 = stream.ReadByte();
int final = 0;
final |= (p1 << 24);
final |= (p2 << 16);
final |= (p3 << 8);
final |= (p4);
return final;
// byte[] b = new byte[4];
// stream.Read(b, 0, 4);
// return (int)System.BitConverter.ToUInt32(b, 0);
}
示例2: ReadMessageHeader
public void ReadMessageHeader(IO.Stream stream, out int length, out PeerMessage type)
{
length = ReadInt(stream);
if (length > 0)
type = (PeerMessage)stream.ReadByte();
else
type = PeerMessage.KeepAlive;
}
示例3: String
/// <summary>Constructs a string from the bEncoded stream</summary>
/// <param name="istream">Stream to construct string from</param>
public String(IO.Stream istream, int firstchar)
{
if (istream.CanSeek)
this.position = (int)istream.Position - 1;
string numstr = new string((char)firstchar, 1);
while (true)
{
int c = istream.ReadByte();
if (c != ':')
numstr += (char)c;
else
break;
}
int length = System.Int32.Parse(numstr);
if (length < 0)
throw new System.Exception("Invalid string length");
this.data = new byte[length];
istream.Read(this.data, 0, length);
if (istream.CanSeek)
this.length = (int)(istream.Position - this.position);
// System.Diagnostics.Debugger.Log(0, "BEncode", "String: " + this.ToString() + "\n");
}
示例4: NextElement
/// <summary>
/// Returns the next element in the stream.
/// </summary>
/// <param name="istream">bEncoded stream to extract element from</param>
/// <returns>bEncode element</returns>
public static Element NextElement(IO.Stream istream)
{
return NextElement(istream, istream.ReadByte());
}
示例5: Dictionary
/// <summary>
/// Constructs a dictionary
/// </summary>
/// <param name="istream">Stream to construct dictionary from</param>
public Dictionary(IO.Stream istream)
{
if (istream.CanSeek)
this.position = (int)istream.Position - 1;
int c;
while ((c = istream.ReadByte()) != 'e')
{
BEncode.String key = new BEncode.String(istream, c); // keys are always strings
string strkey = key;
Element element = BEncode.NextElement(istream);
if (!this.map.Contains(key))
this.map.Add(key, element);
}
if (istream.CanSeek)
this.length = (int)istream.Position - this.position;
}
示例6: List
/// <summary>Constructs an integer from the bEncoded stream</summary>
/// <param name="istream">Stream to construct integer from</param>
public List(IO.Stream istream)
{
if (istream.CanSeek)
this.position = (int)istream.Position - 1;
int c;
while ((c = istream.ReadByte()) != 'e')
{
BEncode.Element element = BEncode.NextElement(istream, c);
string el = element.ToString();
this.list.Add(element);
}
if (istream.CanSeek)
this.length = (int)istream.Position - this.position;
}
示例7: Integer
/// <summary>Constructs an integer from the bEncoded stream</summary>
/// <param name="istream">Stream to construct integer from</param>
internal Integer(IO.Stream istream)
{
if (istream.CanSeek)
this.position = (int)istream.Position - 1;
string numstr = "";
char c;
while ((c = (char)istream.ReadByte()) != 'e')
{
numstr += c;
}
this.integer = System.Int32.Parse(numstr);
if (istream.CanSeek)
this.length = (int)istream.Position - this.position;
}