摘要: A question pops up from the forum regarding the const correctness in C++: “Why don't we have it in C#?” In C++, if a method is declared like this: class MyClass { void foo() const; }; It implies that the author claims that the method won't change any internal data of MyClass object. It's a very handy way to allow compiler to check the semantics of your program. In C#, however, we don't have any corresponding constructs. An explanation from Anders Hejlsberg can be found here (Check out the immutable section).
My understanding of the problem is......[
阅读全文]