Skip to content

Instantly share code, notes, and snippets.

@Rudde
Rudde / ProgressBar.cs
Created October 7, 2020 09:55
Let you have a moving progressbar in a C# console app.
public class ProgressBar : IDisposable, IProgress<double>
{
private const int blockCount = 10;
private readonly TimeSpan animationInterval = TimeSpan.FromSeconds(1.0 / 8);
private const string animation = @"|/-\";
private readonly Timer timer;
private double currentProgress = 0;
private string currentText = string.Empty;
@Rudde
Rudde / HumanReadableBytes.cs
Created October 8, 2020 10:58
Will convert bytes into readable data units.
using System.Collections.Generic;
using System.Globalization;
namespace HumanReadable
{
public class HumanReadableBytes
{
private readonly Dictionary<Base, Unit[]> _baseUnits = new Dictionary<Base, Unit[]>();
public int DecimalPoints = 2;
public int DecimalsAfterPower = 2;