C#控制台进度条(Programming Progress bar in C# Consle application)
以下代码从Stack Overflow,觉得以后会用到就收藏一下,我是辛勤的搬运工,咿呀咿呀哟~
1.showing percentage in .net console application(在.NET控制台程序里显示百分比进度)
采纳答案1:
using System;
using System.Threading; namespace Progress
{
class Program
{
static void Main(string[] args)
{
for (int i = ; i <= ; i++)
{
Console.Write("\r{0}%", i);
Thread.Sleep(50);
}
}
}
}
效果图:

以下代码来自采纳答案1的评论区
using System;
using System.Threading; namespace Progress
{
class Program
{
static void Main(string[] args)
{
for (int i = ; i <= ; i++)
{
if (i == )
{
Console.Write("\rDone!");
}
else
{
Console.Write("\r{0}%", i);
Thread.Sleep();
}
}
}
}
}
效果图

using System;
using System.Threading; namespace Progress
{
class Program
{
static void Main(string[] args)
{
for (int i = ; i <= ; i++)
{
Console.Write("\r{0,3}%", i);//3个0占位符
Thread.Sleep();
}
}
}
}
效果图:

using System;
using System.Threading; namespace Progress
{
class Program
{
static void Main(string[] args)
{
for (int i = ; i <= ; i++)
{
Console.Write("\r{0,3}%", i); //3个空格占位符
Thread.Sleep();
}
}
}
}
效果图:

其他资料:
Progress bar in console application
how to use text based console progress bar in multithreading C#
C#控制台进度条(Programming Progress bar in C# Consle application)的更多相关文章
- 打印进度条——(progress bar才是专业的)
# 打印进度条——(progress bar是专业的) import time for i in range(0,101,2): time.sleep(0.1) char_num = i//2 #打印 ...
- 用C#实现控制台进度条
在写一些简单的控制台测试程序时,经常希望能够在程序运行的过程中实现进度条的功能以便查看程序运行的速度或者进度.本文以C#为例,实现简单的控制台进度条,以供大家参考(本文底部附下载地址). 1.实现效果 ...
- [c#]控制台进度条的示例
看到[vb.net]控制台进度条的示例 感觉很好玩,翻译成C#版. using System; using System.Collections.Generic; using System.Linq; ...
- Python中如何写控制台进度条的整理
本文实例讲述了Python显示进度条的方法,是Python程序设计中非常实用的技巧.分享给大家供大家参考.具体方法如下: 首先,进度条和一般的print区别在哪里呢? 答案就是print会输出一个\n ...
- Python 控制台进度条的实现
进行爬虫等耗时的任务时,有时会想在控制台输出进度条,以显示当前任务进度.这里总结了两种方法. 方法1:使用tqdm模块 示例代码: from time import sleep from tqdm i ...
- ruby 编写控制台进度条
ruby 中,$stdout.flush 让控制台当前行内容可以重写,以此我们可以做出进度条的效果. def set_progress(index, char = '*') print (char * ...
- iOS 实现进度条(progress)
#import <UIKit/UIKit.h> @interface ZSDProgressView : UIView { UIView *progressView;//进度view } ...
- [vb.net]控制台进度条的示例
Private Sub ConsoleProcessBar() Dim isBreak As Boolean = False Dim colorBack As ConsoleColor = Conso ...
- 如何在UIAlertView中显示进度条
今天这个问题是,在一个iPhone程序中,我要在后台做大量的数据处理,希望在界面上显示一个进度条(Progress Bar)使得用户了解处理进度.这个进度条应该是在一个模态的窗口中,使界 今天这个问题 ...
随机推荐
- 基于RDBMS的OLAP的解决方案
BI项目如何开发: 了解OLAP的分析方法: 对数据进行多维建模分析,也就是自己设计自己的数据方体,之后程序自动生成数据方体 数据方体: 1.自动成的表结构,仅仅有你需要的列 2.生成一条SQL语句( ...
- 面向服务的SOA架构与服务总线ESB
之前的软件的开发主要是面向对象的编程架构 方法---对象---模块---组件---服务,感觉现在的开发的主流的软件架构的设计思想都是对其进行重用,只不过范围越来越大,有一个系统之间进行通信到多个系统之 ...
- 使用SolrNet访问Solr-5.5.0
由于今年年初刚发布的Solr-5.5.0,网上所能找到的资料少之又少,所以只能靠自己一点点摸索. 从某Hub上下载了SolrNet源码,按照教程提交文档或者查询均失败,无奈只得跟断点一点点差怎么回事. ...
- 洛谷P1414 又是毕业季II
题目背景 “叮铃铃铃”,随着高考最后一科结考铃声的敲响,三年青春时光顿时凝固于此刻.毕业的欣喜怎敌那离别的不舍,憧憬着未来仍毋忘逝去的歌.1000多个日夜的欢笑和泪水,全凝聚在毕业晚会上,相信,这一定 ...
- Pillow 读取图片截断错误
做图像处理的时候,Pillow是经常使用到的模块. 最近在读取图片的时候出现了一个错误. OSError: image file is truncated (461 bytes not process ...
- ByteCache
private static class ByteCache { private ByteCache(){} //256个元素,用于缓存-128到127 static final Byte cache ...
- jquery easyui iconcls(小图标)属性的设置
今天用easyui做accordion的时候,觉得它自带的图标不够漂亮,想换成自己的图标,可是菜鸟我不知道怎么设置,上网查找,因为问题太水了,找不到,只好自己摸索,现在终于解决了,所以记录下来,同时也 ...
- leetcode521
public class Solution { public int FindLUSlength(string a, string b) { : Math.Max(a.Length, b.Length ...
- windows系统安装参数
winnt32 /dudisable /s:. /unattend:winnt.sif /makelocalsource /tempdrive:C /syspart:C 以上各参数解释如下: /dud ...
- 前端-javascript-BOM-浏览器对象模型
BOM的介绍---浏览器对象模型. 操作浏览器部分功能的API.比如让浏览器自动滚动. -------------------------------------------------------- ...