The C# compiler doesn't know about const in a method definition, so it can't 
differentiate between the methods.  I don't believe the CLR understands this 
use of const either, so the IL generated will be the same.

-----Original Message-----
From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] 
On Behalf Of Bogdan Lachendro
Sent: Friday, November 19, 2004 9:11 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] const modifier in method parameter - managed c++

Hi,

Lets say I have a  class:

        public __gc class MyClass
        {
     public:

         void foo(MyClass* const a)
         {
         }

         void foo(const MyClass* a)
         {
         }
        };

Why is the IL code generated by MVC++ the same for both those methods?
Is there any way to use such method in C# code? Currently I have:

e:\classlibrary1\class1.cs(34,13): error CS0121: The call is ambiguous
between the following methods or properties:
'ManagedClass.MyClass.foo(ManagedClass.MyClass)' and
'ManagedClass.MyClass.foo(ManagedClass.MyClass)'

Thanks,

Regards,
Bogdan

===================================
This list is hosted by DevelopMentorŽ  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŽ  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to