Skip to content

Instantly share code, notes, and snippets.

@booyaa
Created October 4, 2013 11:43
Show Gist options
  • Save booyaa/6824676 to your computer and use it in GitHub Desktop.
Save booyaa/6824676 to your computer and use it in GitHub Desktop.
C# one liners

###get byte size of string

usually String.Length should be sufficient, but yeah unicode.

Console.WriteLine("Hello World is {0} bytes", Encoding.UTF8.GetByteCount("Hello World"));

source: http://stackoverflow.com/a/9761824/105282

###get memory usage in bytes of process

Console.WriteLine("Current mem usage is {0} bytes", System.Diagnostics.Process.GetCurrentProcess().WorkingSet64);

source: http://stackoverflow.com/a/755949/105282

###repeat string

Console.WriteLine("{0}", String.Concat(Enumerable.Repeat("Hello World\n", 50)));

source: http://stackoverflow.com/a/7601526/105282

###repeat characters

Console.WriteLine("{0}", new String('-', 50));

source: prolly so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment