Tips for optimizing C#/.NET programs
- by Bob
It seems like optimization is a lost art these days. Wasn't there a time when all programmers squeezed every ounce of efficiency from their code? Often doing so while walking 5 miles in the snow?
In the spirit of bringing back a lost art, what are some tips that you know of for simple (or perhaps complex) changes to optimize C#/.NET code? Since it's such a broad thing that depends on what one is trying to accomplish it'd help to provide context with your tip. For instance:
When concatenating many strings together use StringBuilder instead. If you're only concatenating a handful of strings it's ok to use the + operator.
Use string.Compare to compare 2 strings instead of doing something like string1.ToLower() == string2.ToLower()