Link Details

Link 87709 thumbnail
User 281687 avatar

By paul_houle
via gen5.info
Published: Jun 16 2008 / 11:57

C# offers two casting operators: the prefix-cast and the as-cast. Although the two operators compile to different op-codes in the CLR, the practical difference between them is in how they handle failed casts. Prefix-cast throws an exception on cast failure, while as-cast returns null. It’s easier to implement correct error handling when you use prefix cast, because it doesn’t require manual checks for null values that can cause problems in distant parts of your program. Prefix-cast should be the default cast operator on your fingertips, that you use for everyday situations
  • 11
  • 1
  • 875
  • 186

Comments

Add your comment
User 289034 avatar

SilvioSuller replied ago:

0 votes Vote down Vote up Reply

to basic

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.