当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.ReadByte方法代码示例

本文整理汇总了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);
		}
开发者ID:peteward44,项目名称:torrent.net,代码行数:17,代码来源:peerprotocol.cs

示例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;
		}
开发者ID:peteward44,项目名称:torrent.net,代码行数:9,代码来源:peerprotocol.cs

示例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");
			}
开发者ID:peteward44,项目名称:torrent.net,代码行数:28,代码来源:bencode.cs

示例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());
		}
开发者ID:peteward44,项目名称:torrent.net,代码行数:9,代码来源:bencode.cs

示例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;
			}
开发者ID:peteward44,项目名称:torrent.net,代码行数:23,代码来源:bencode.cs

示例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;
			}
开发者ID:peteward44,项目名称:torrent.net,代码行数:19,代码来源:bencode.cs

示例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;
			}
开发者ID:peteward44,项目名称:torrent.net,代码行数:17,代码来源:bencode.cs


注:本文中的System.IO.ReadByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。