Ray's playground

 

2011年1月9日

Item 4: Use Conditional Attributes Instead of #if(Effective C#)

摘要: The Conditional attribute generates more efficient IL than #if/#endifdoes. It also has the advantage of being applicable only at the functionlevel, which forces you to better structure your conditional code. The compileruses the Conditional attribute to help you avoid the common errorswe have all ma 阅读全文

posted @ 2011-01-09 22:31 Ray Z 阅读(231) 评论(0) 推荐(0) 编辑

Item 3: Prefer the is or as Operators to Casts(Effective C#)

摘要: Remember that user-defined conversion operators operate only on thecompile-time type of an object, not on the runtime type.  Now that you know to use as when possible, let’s discuss when you can’tuse it. The as operator does not work on value types.  The is operator should be used only when you cann 阅读全文

posted @ 2011-01-09 11:16 Ray Z 阅读(213) 评论(0) 推荐(0) 编辑

导航