TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C# Coding Standard
Search

Rule:  7@201

Synopsis:Selection statements (if-else and switch) should be used when the control flow depends on an object's value; dynamic binding should be used when the control flow depends on the object's type
Language:C#
Severity Level:9
Category:Object oriented


Description:

This is a general OO principle. Please note that it is usually a design error to write a selection statement that queries the type of an object (keywords typeof, is). Dynamic binding (e.g. using class inheritance) is a much better choice then.

Exception:

Using a selection statement to determine if some object implements one or more optional interfaces is a valid construct though.