Geeks With Blogs
shmoolca wpf programming
Main difference is that casting to wrong type throw an exception and an “as” keyword just return null. So if I would like to search specified type in VisualTree I can use “as” keyword and check is object not null or I can use “is” keyword. But when I would like to take not reference object like generics KeyValuePair from object type I will have to use casting to unpack the value type. This is because value types do not inherit from object so they are not objects and cannot use keyword as. Posted on Tuesday, July 14, 2009 5:52 PM Memorandum | Back to top

Comments on this post: Differences between casting and „as” keyword

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Anna Bauza | Powered by: