Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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;

...


}

I found the following links on internet about coding standards while fixing some issues:
document on coding standards
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 in Microsoft .NET 2.0