...
No Format |
---|
protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { // Dispose managed resources. } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } disposed = true; // If it is available, make the call to the // base class's Dispose(Boolean) method base.Dispose(disposing); } |
Often people cast an object multiple times, leading to small performance degradation
No Format |
---|
if (myobject is IDataItem) //first cast
{
node.Tag = ((IDataItem)myObject).Value; // second cast.
}
|
This can be done a bit more efficient in the following way:
No Format |
---|
IDataItem item
if ((item = myObject as IDataItem) != null) //first cast.
{
node.Tag = item.Value;
}
|
Links
I found the following links on internet about coding standards while fixing some issues:
document on coding standards
Exception throwing
Exception handling
FxCop, locale installatie
Using CultureInfo.InvariantCulture
Writing your own fxcop rules
When and how to dispose and finalize in c#
Why StringComparison.Ordinal is usually the right choice
New Recommendations for Using strings Strings in Microsoft .Net NET 2.0