Open Bo's first article always have some sincerity, share a self-written Remote Desktop tools: Https://github.com/wang9563/RemoteDesktopManage
This is also a year ago written code, the company has a lot of cloud host to manage, colleagues can not find the right tool to write one, the code is not complex, but the quality is not flattering. At least the progress of the year has been some, but a few like-minded friends, this year's spare time did not do anything. Just the beginning to forget how to write, simply list the accumulation of their own, want to fill the bad.
I'm generally used to simplifying code, but most of it is blind simplification, and occasionally anti-compilation checks to see if I can simplify.
For example, when solving ToString (), prevent NullReferenceException I'm used to adding an empty string to a variable.
Roost, I must have written this:
Public string GetResult (string str) { return"";}
In some cases it is not possible to be in the usual position:
Public string GetResult (object obj) { //return obj?? ""; return NULL "" : obj. ToString ();}
With ternary operator is always uncomfortable, although he wrote CodeSnippet, but still unwilling!
So I started writing this:
Public string GetResult (object obj) { return"";}
This is the case after compiling:
The following parameter is a good understanding of the string type, but what is the return (obj) above?
Had to turn into IL and see:
Oh, string. Concat!!!
Haha, great compiler!
Another one was amazed by the code of an unknown great God:
The next two lines are added, huh? Add an entire meeting, pull down the grid? I changed it too.
Public stringConverttochinese (decimalNumber ) { varformat = number. ToString ("#L #e#d#c#k#e#d#c#j#e#d#c#i#e#d#c#h#e#d#c#g#e#d#c#f#e#d#c#.0b0a"). Replace ("0b0a","@"); varSimplify = Regex.Replace (format,@"((? <=-|^) [^1-9]*) | ((?‘ Z ' 0) [0a-e]* ((? =[1-9]) | (? ') -Z ' (? =[f-l\.]| $))))| ((?‘ B ' [f-l]) (? ') Z ' 0) [0a-l]* ((? =[1-9]) | (? ') -Z ' (? =[\.]| $))))","${b}${z}"); varresult = Regex.Replace (Simplify,".", match ="negative yuan empty 0 three Woolu qi ba nine empty empty air empty whole point of hundred trillion trillion Zhao Beijing gai trillion joi"[Match. value[0] -'-']. ToString ()); returnresult;}
To sum up, I am a person who does not pay any price to simplify the code, run/development efficiency sometimes really slow, but look cool AH ~
It was written out of the code that could not be deleted, and I had to wrap it up with #region #endregion and Mark 1234, by the way, I learned shortcut: CTRL + M, CTRL + O
The first blog, a bit tongue-tied, look at the audience forgive me, I just hope to meet some like-minded friends.
Simplified code regardless of cost