开发者

When to use the "as" keyword and when to use () casting? [duplicate]

开发者 https://www.devze.com 2023-02-02 06:22 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: Direct casting vs 'as' operator?
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Direct casting vs 'as' operator?

as doesn't throw an exception, but开发者_运维技巧 wouldn't it result in a NullPointerException later? doesn't it make it harder to debug?


after using the as, you should always check for null.

0

精彩评论

暂无评论...
验证码 换一张
取 消