当前位置: 首页 > 生活百科 > 学习帮助 > ◆●用了is为什么还要用as?Textbox temp=null;foreach(Control control in

◆●用了is为什么还要用as?Textbox temp=null;foreach(Control control in

网站编辑:宽屏壁纸网 发布时间:2022-08-13  点击数:
导读:●用了is为什么还要用as?Textbox temp=null;foreach(Control control in ●用了is为什么还要用as?Textbox temp=null;foreach(Control control in this.Controls){if(control is textbox) temp= control as Textbox; }为什么前面用...

◆●用了is为什么还要用as?Textbox temp=null;foreach(Control control in

◆●用了is为什么还要用as?
Textbox temp=null;
foreach(Control control in this.Controls)
{
if(control is textbox) temp= control as Textbox;
}
为什么前面用了is检查了 这里还要用as呢?is检查后 不就确定了类型吗?确定了类型 那就不用as转换了啊 直接temp= control 这样不行吗? dd是两个口 1年前他留下的回答 已收到1个回答

astrit 网友

该名网友总共回答了17个问题,此问答他的回答如下:采纳率:100%

is 可以看做是==的符号,相当于比对
as是赋值
2个单词,在C#中的含义是不同的

1年前他留下的回答

2

  以上就是小编为大家介绍的◆●用了is为什么还要用as?Textbox temp=null;foreach(Control control in 的全部内容,如果大家还对相关的内容感兴趣,请持续关注宽屏壁纸网!

  标签:
内容声明:网站所展示的内容均由第三方用户投稿提供,内容的真实性、准确性和合法性均由发布用户负责。诚智拓展网对此不承担任何相关连带责任。诚智拓展网遵循相关法律法规严格审核相关关内容,如您发现页面有任何违法或侵权信息,欢迎向网站举报并提供有效线索,我们将认真核查、及时处理。感谢您的参与和支持!
浏览此文的人还看过
一个关于外貌的英语对话(2人)
一个关于外貌的英语对话(2人)

详情:一个关于外貌的英语对话(2人) ......

淀粉是胶体吗
淀粉是胶体吗

详情:淀粉是胶体吗 ......

英语翻译用英语
英语翻译用英语

详情:英语翻译用英语 ......

凛字组什么词?2字的
凛字组什么词?2字的

详情:凛字组什么词?2字的 ......