-
Notifications
You must be signed in to change notification settings - Fork 1
Home
DUONG Phu-Hiep edited this page Nov 16, 2015
·
16 revisions
My collection of many small useful code-snippet .net, wrapping in reusable library with unobtrusive dependencies. Some of the most-used library are published on nuget.
https://www.nuget.org/profiles/duongphuhiep
- No dependencies
- Use to display some C# object.
- Know to convert a IEnummerable to string in order do display in a log message
var arr = new string[1000] {"item1".."item1000"};
arr.Display().SeparatedBy("; ").MaxItems(4)
gives
{ item1; item2; item3; item4; ..and 996 (of 1000) more }
- if the some of the items is very long to display in the log file
var arr = new string[1000] {"Lorem ipsum kidda foom", "item2".."item1000"};
arr.Display().MaxItems(4).MaxItemLength(10)
gives
{ [[Lorem...]], item2, item3, item4, ..and 996 (of 1000) more }
- Fast performance it only iterate neccessary items once (complexity O(N))
- see more functionalities in code and test
convert Stopwatch
to string
Stopwatch sw;
Console.WriteLine(sw.DisplayMili()); //get the display string in mili seconds "103 ms"
Console.WriteLine(sw.DisplayMicro()); //get the display string in micro seconds "103,000 mcs"
Console.WriteLine(sw.Display()); //automaticly choose a time unit (day, hour, minute, seconde..) to display