0

i have very basic doubt - from performance point of view "is" cast or "as" cast is better to use. Though "as" does not throw exception but it does boxing and hence performance gets affected but still not sure.

if possible please give example for this

sia
  • 1,872
  • 1
  • 23
  • 54
  • Completely depends on how it is being used - `is` returns a boolean to determine a type, `as` casts it to that type if possible to use the object – Sayse Feb 24 '15 at 10:51
  • its highly unlikely that either are going to have a measurable impact on the performance of your application. Try it and see? – Justin Feb 24 '15 at 10:53
  • Wrong duplicate, should be [this one](http://stackoverflow.com/q/3786361/1997232). – Sinatr Feb 24 '15 at 10:53
  • it does not look like duplicate.. – user1291401 Feb 24 '15 at 10:54
  • @Sinatr : There is no clear answer to the question in the post. But if you need the cast anyway go for `as`. If you don't go for `is`! – TaW Feb 24 '15 at 11:13
  • @TaW, linked question contains answers which explains difference between `as` and `is`. Performance conclusion is given by tests usually. – Sinatr Feb 24 '15 at 11:17

0 Answers0