[英]Dependencies not found in .Net Core console application - showing as missing on startup
[英]showing percentage in .net console application
我有一個控制台應用程序執行一個漫長的過程。
我在新線上打印完成百分比, 每完成1% 。
如何讓程序在控制台窗口的相同位置打印完成百分比?
打印\\r
返回到行的開頭(但不要打印換行符!)
例如:
using System;
using System.Threading;
class Test
{
static void Main()
{
for (int i=0; i <= 100; i++)
{
Console.Write("\r{0}%", i);
Thread.Sleep(50);
}
}
}
你可以使用:
Console.SetCursorPosition();
適當地設定位置。
像這樣:
Console.Write("Hello : ");
for(int k = 0; k <= 100; k++){
Console.SetCursorPosition(8, 0);
Console.Write("{0}%", k);
System.Threading.Thread.Sleep(50);
}
Console.Read();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.