st
2 楼
what's the real use for the difference?
I found below URL:
http://www.c-sharpcenter.com/Tutorial/ConstVsReadOnly.htm
【在 E*******s 的大作中提到】
: what is difference between const and readonly?
I found below URL:
http://www.c-sharpcenter.com/Tutorial/ConstVsReadOnly.htm
【在 E*******s 的大作中提到】
: what is difference between const and readonly?
s*i
3 楼
Example: Suppose we have an ArrayList. Its filed "Count" is readonly, but
definitly not "const".
【在 st 的大作中提到】
: what's the real use for the difference?
: I found below URL:
: http://www.c-sharpcenter.com/Tutorial/ConstVsReadOnly.htm
definitly not "const".
【在 st 的大作中提到】
: what's the real use for the difference?
: I found below URL:
: http://www.c-sharpcenter.com/Tutorial/ConstVsReadOnly.htm
C*n
5 楼
All right guys.
1. Const can not be changed, and can only be declared in the field
declaration.
i.e.: public const int i=5;
2. const automatically means static.
3. Readonly can be asigned in CONSTRUCTOR!
The real world concern:
Never declare a public field as CONST (static), use readonly
instead, which will save you from recompilation if the const in the underlying
library is
recompiled. Only use const with your private field.
Well, a better pratice is never declare public field.
The Count in Ar
【在 a**y 的大作中提到】
: const can not be changed in any case, readonly can not be changed by you. :)
1. Const can not be changed, and can only be declared in the field
declaration.
i.e.: public const int i=5;
2. const automatically means static.
3. Readonly can be asigned in CONSTRUCTOR!
The real world concern:
Never declare a public field as CONST (static), use readonly
instead, which will save you from recompilation if the const in the underlying
library is
recompiled. Only use const with your private field.
Well, a better pratice is never declare public field.
The Count in Ar
【在 a**y 的大作中提到】
: const can not be changed in any case, readonly can not be changed by you. :)
s*i
9 楼
This is a good explanation. I got the concept wrong.
underlying
of
【在 C****n 的大作中提到】
: All right guys.
: 1. Const can not be changed, and can only be declared in the field
: declaration.
: i.e.: public const int i=5;
: 2. const automatically means static.
: 3. Readonly can be asigned in CONSTRUCTOR!
: The real world concern:
: Never declare a public field as CONST (static), use readonly
: instead, which will save you from recompilation if the const in the underlying
: library is
underlying
of
【在 C****n 的大作中提到】
: All right guys.
: 1. Const can not be changed, and can only be declared in the field
: declaration.
: i.e.: public const int i=5;
: 2. const automatically means static.
: 3. Readonly can be asigned in CONSTRUCTOR!
: The real world concern:
: Never declare a public field as CONST (static), use readonly
: instead, which will save you from recompilation if the const in the underlying
: library is
L*r
10 楼
Your explain is clear. //admire
Actually, just think about the reason why C++ introduces const.
Then we will know the basic feature of const le. :)
underlying
of
【在 C****n 的大作中提到】
: All right guys.
: 1. Const can not be changed, and can only be declared in the field
: declaration.
: i.e.: public const int i=5;
: 2. const automatically means static.
: 3. Readonly can be asigned in CONSTRUCTOR!
: The real world concern:
: Never declare a public field as CONST (static), use readonly
: instead, which will save you from recompilation if the const in the underlying
: library is
Actually, just think about the reason why C++ introduces const.
Then we will know the basic feature of const le. :)
underlying
of
【在 C****n 的大作中提到】
: All right guys.
: 1. Const can not be changed, and can only be declared in the field
: declaration.
: i.e.: public const int i=5;
: 2. const automatically means static.
: 3. Readonly can be asigned in CONSTRUCTOR!
: The real world concern:
: Never declare a public field as CONST (static), use readonly
: instead, which will save you from recompilation if the const in the underlying
: library is
a*y
11 楼
o. I thought the 'readonly' in the question is an attribute
instead of a data type modifier.
And I didn't know C# has a 'readonly' modifier until now. //blush
【在 C****n 的大作中提到】
: All right guys.
: 1. Const can not be changed, and can only be declared in the field
: declaration.
: i.e.: public const int i=5;
: 2. const automatically means static.
: 3. Readonly can be asigned in CONSTRUCTOR!
: The real world concern:
: Never declare a public field as CONST (static), use readonly
: instead, which will save you from recompilation if the const in the underlying
: library is
instead of a data type modifier.
And I didn't know C# has a 'readonly' modifier until now. //blush
【在 C****n 的大作中提到】
: All right guys.
: 1. Const can not be changed, and can only be declared in the field
: declaration.
: i.e.: public const int i=5;
: 2. const automatically means static.
: 3. Readonly can be asigned in CONSTRUCTOR!
: The real world concern:
: Never declare a public field as CONST (static), use readonly
: instead, which will save you from recompilation if the const in the underlying
: library is
相关阅读
MVC效率高一些,可是大项目也不可以推倒重做呀。.NET 和 Java 的轮回why-java-sucks-and-c-rocks-final有用过spring.net 和 Nhibernate的大牛吗?linq在debug的时候看不出错误的地方啊。dotnet hosting dealnhibernate, ado.net比stored procedure执行数据库操作快吗?请教 pass by value or reference 的问题菜鸟继续问: 如果一个db file打开在ms sql studio里,c# code可以同时对他操作吗?有人知道为啥azure的cloud service deploy这么慢?php + mysql + javascript 对应 vb.net / asp.net / sql serverc# 用code 做的chart太丑了,大家用什么插件来让它变fancy点。WEB API能替代WCF不how to programatically fill the form and submit it请推荐sharepoint编程的书或资料Re: 又开始认证了SQL 2012 (转载)vs2012怎么拿掉了那么多有用的功能it is a pity windows 8 didn't get recognizedScott Hanselman's 2011 Ultimate Developer and Power Users Tool List for Windows有谁在做drupal programming吗? (转载)