Try to consume your managed class from another managed client, written in C++. If MC++ will put the const modifier on the parameter, it should also use it to select the appropriate method. I'm switching to MC++ if this works :)
Cheers, Stoyan -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Bogdan Lachendro Sent: Friday, November 19, 2004 4:44 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] const modifier in method parameter - managed c++ On 2004-11-19 15:36, David Barnhill wrote: > 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. AFAIK CLR itself understands the const modifier (the apropriate custom modifier should be added to the method parameter). The problem is that the code generated by the managed c++ compiler is the same for both those methods below - and this is strange to me. Regards, Bogdan > > -----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 > > -- Bogdan Lachendro mailto:lachu(at)poczta.fm http://www.the.king.of.pl TEL +48606318657 UIN 66844735 GG 1469796 A wise man changes his mind, a fool never will... =================================== 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
