加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 使用null转换为变量的数据类型初始化变量

发布时间:2020-12-16 02:03:41 所属栏目:百科 来源:网络整理
导读:我遇到了一些像这样的代码: Liststring list = (Liststring)null; 有没有理由程序员不只是初始化: Liststring list = null; 这两者有区别吗? 这是从另一种编程语言迁移的习惯吗?也许C,C或Java? 解决方法 Is there a difference between the two? 没有没
我遇到了一些像这样的代码:

List<string> list = (List<string>)null;

有没有理由程序员不只是初始化:

List<string> list = null;

这两者有区别吗?

这是从另一种编程语言迁移的习惯吗?也许C,C或Java?

解决方法

Is there a difference between the two?

没有没有区别.

在ILSpy中,此行列表< string> list =(List< string>)null;更改为List< string> list = null;

Is this a habit that migrated from another programming language?

不能说.可能是,早些时候有一些不同于null的东西然后它被改为null.

List<string> list = (List<string>) Session["List"];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读