C# Optimization Tips

Work in progress; feel free to have a look. :)

Posted by Rishi Raj Gujadhur 2/15/2016


 
Prerequisites
 
A. What is code optimization?
 
B. Static Fields
 
C. If vs Switch
 
D. StringBuilder vs string
 
E. Structs vs Classes
 
F. ToString
 
G. Arrays
 
H. Dictionary
 
I. Avoid re-throwing Exceptions
 
J. Avoid Parameters
 
K. For vs Foreach
 
L. Arrays vs Generic lists
 
M. String.Empty
 
N. ArrayLists vs Lists
 
O. Where with First instead of FirstOrDefault