解释差异“IS”。和“作为”在C#? [英] Explain the differences "IS" and "as" in C#?

查看:79
本文介绍了解释差异“IS”。和“作为”在C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Explain the differences  "IS" and "AS" in C#?





我是什么尝试过:





What I have tried:

Explain the differences  "IS" and "AS" in C#?

推荐答案

尝试查看文档,它将提供完整的描述。
Try looking at the documentation, it will provide a complete description.


is询问是否可以进行转换,as进行转换。



"is" asks if a conversion can be done, "as" does the conversion.

bool canBeDone = a is SomeType;
SomeType st = a as SomeType;


这篇关于解释差异“IS”。和“作为”在C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆