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
