Readonly and other things about C++

本文探讨了C#与C++之间的主要区别,重点介绍了C#中readonly特性的使用方式及其与C++中const关键字的不同之处。文章还讨论了在C#中使用静态成员变量及方法的场景,并建议读者关注《Effective C#》一书中介绍的重要概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. in c#

readonly can be delayed to initialize in constructor.

 

2. in c++

totally no readonly.

 

Many people have mastered c++ before c#. They are the managers.

So many of the interview are about the difference of c# and c++.

I am always confused about the interview problems since I never use it before.

Such as readonly. In c#, there are no pointer, we don't need const and readonly actually.

All you need to do is set a All caps up variable name as a field. such as:

class A 

{

double MYPI=0.7;

}

I am sure none will try to change it in the methods. The same for static. Only one way I will use static:

when I need to use a static method. That is all. Please forget the differece of static readonly and const.

We don't need it totally.

 

When I interviewed with Microsoft one year ago.

I am aware of that, the most important things of c# are all in Effective C#.

If you understand all items, you understand how to use c#.

  

 

转载于:https://www.cnblogs.com/gaoxianzhi/p/4423580.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值