Recipe 3.14 Determining Whether to Use theCast Operator, the as Operator, or theis OperatorProblemYou need to determine which operator is best in your situation the cast ( type )-- operator, the as operator, or the is operator. SolutionUse the information provided in the Discussion section to determine which operator is best to use. DiscussionThe cast operator should be used when:
The as operator should be used when:
The is operator should be used when:
See AlsoSee Recipe 3.15 and Recipe 3.16; see the "( ) Operator," "as Operator," and "is Operator" topics in the MSDN documentation. |