我知道有一种方法可以使for
循环像while
循环一样工作。如何使`for`循环像'while`循环一样工作?
我有这样的代码工作:
while (BR.BaseStream.Position < BR.BaseStream.Length) // BR = BinaryReader
{
int BlockLength = BR.ReadInt32();
byte[] Content = BR.ReadBytes(BlockLength);
}
我需要相当于这个while
循环for
..
到目前为止,我有这样的:
for (long Position = BR.BaseStream.Position; Position < BR.BaseStream.Length; //Don't Know This)
{
int BlockLength = BR.ReadInt32();
byte[] Content = BR.ReadBytes(BlockLength);
}
为什么要这么做?为什么不使用这一边看自己? – Ramesh
闻起来像功课。 – dwerner
@dwerner不是作业,因为这是我最近的项目!实际上,我想将所有'while'循环传递给for循环 – Writwick