On Wed, 22 May 2002 17:21:41 -0400, Sam Gentile <[EMAIL PROTECTED]>
wrote:

>I haven't found this in C#. Does C# have the equivalent of C++'s const
>parameters or const methods? This is common in C++:
>void Foo(const string& str)

No. The nearest you can get is to split a type into two, put the const
methods in the first class, and put the non-const methods in the second
class and derive the second class from the first class. Of course you
could split it into 2 interfaces if you wanted. All in all, a lot of work.

Note also that
/1/ you cannot split get/set accessors.
/2/ you can never stop simple assignment for a user defined type.
/3/ if you write E.M(...) and E is not classified as a variable then
you're actually calling M on a copy of E.

HTH
Cheers
Jon Jagger

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to