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

在C#中,“Customer cust = new Customer();”是做什么的?

发布时间:2020-12-15 18:36:03 所属栏目:百科 来源:网络整理
导读:Customer cust = new Customer(); 客户是一个班级. cust是指定的名称.我不确定Customer()做了什么…… 这条线做什么?我们为什么需要它?没有客户和客户()有点重复? 解决方法 它声明一个客户,然后初始化它. Customer cust; //declares a new variable of Cu
Customer cust = new Customer();

客户是一个班级. cust是指定的名称.我不确定Customer()做了什么……

这条线做什么?我们为什么需要它?没有客户和客户()有点重复?

解决方法

它声明一个客户,然后初始化它.
Customer cust; //declares a new variable of Customer type

cust = new Customer(); //Initializes that variable to a new Customer().

new创建实际对象,cust hold是对它的引用.

空括号表示Customer对象的构造没有传递任何参数,否则括号内将有逗号分隔的参数列表.

(编辑:李大同)

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

    推荐文章
      热点阅读