Skip to content

Instantly share code, notes, and snippets.

@kflu
Last active May 12, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kflu/9b33a246250ac4ba635ffb3621ce18bf to your computer and use it in GitHub Desktop.
Save kflu/9b33a246250ac4ba635ffb3621ce18bf to your computer and use it in GitHub Desktop.
C# IO
// 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