(Console.BufferHeight) I can't see/scroll to see all the console output with Console.WriteLine

后端 未结 5 862
灰色年华
灰色年华 2020-12-20 14:25

When I run this code, the number at the top of the output window is 99701. Why don\'t I get to see all the way through 1? I actually see all the numbers getting outputted, b

5条回答
  •  青春惊慌失措
    2020-12-20 14:41

    From .Net Framework 2.0 and beyond, you can change the buffer height from within your own program with Console.BufferHeight:

    
    Console.BufferHeight = Int16.MaxValue - 1; // ***** Alters the BufferHeight *****
    List myList = new List();
    for (int x = 0; x < 100000; x++) 
        myList.Add(x.ToString()); 
    foreach (string s in myList) { 
        Console.WriteLine(s); 
    }
    

    The maximum height is Int16.MaxValue - 1.

提交回复
热议问题