Last active
May 12, 2018 18:52
-
-
Save kflu/9b33a246250ac4ba635ffb3621ce18bf to your computer and use it in GitHub Desktop.
C# IO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read from stdin (TextReader) | |
static IEnumerable<string> ReadLines(TextReader sr) | |
{ | |
string line; | |
while (null != (line = sr.ReadLine())) yield return line; | |
} | |
// Parse command line | |
using CommandLine; | |
public class Config | |
{ | |
[Option('d', "debug")] | |
public bool Debug { get; set; } | |
} | |
CommandLine.Parser.Default.ParseArguments<Config>(args) | |
.WithParsed<Config>(Process); | |
// string formatting | |
// https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-pad-a-number-with-leading-zeros |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment