网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

C#构造函数怎么初始化

时间:2024-10-13 00:43:42

1、给你写个简单的构造函数class B{ private String a; private String x; public B(String a,String x) { this.a = a ; this.x = x ; } }

2、class A{ B b = new B("hello","world") ;}你要明白定义构造函数的意义,这样构造函数得意义就是给类属性定义了。

© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com