当我运行此代码时,输出窗口顶部的数字是 99701。为什么我看不到一直到 1 的数字?我实际上看到所有数字都被输出,但在控制台窗口上,我只能滚动到足够高才能看到 99701 (我猜)。我在 Vista Home 上使用 Visual C# Express。 :D
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using utilities;
namespace Testing_Project {
class Program {
static void Main(string[] args) {
List<string> myList = new List<string>();
for (int x = 0; x < 100000; x++)
myList.Add( x.ToString() );
foreach (string s in myList) {
Console.WriteLine(s);
}
Console.Read();
}
}
}
Console.Write(s) 可以,但 Console.Write( s+"\n") 不行。我猜我只能向上滚动这么多换行符?
从 .Net Framework 2.0 及更高版本开始,您可以在自己的程序中更改缓冲区高度:控制台.BufferHeight http://msdn.microsoft.com/en-us/library/system.console.bufferheight.aspx:
Console.BufferHeight = Int16.MaxValue - 1; // ***** Alters the BufferHeight *****
List<string> myList = new List<string>();
for (int x = 0; x < 100000; x++)
myList.Add(x.ToString());
foreach (string s in myList) {
Console.WriteLine(s);
}
最大高度为 Int16.MaxValue - 1。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)