using System; using System.Collections.Generic; using System.Text; namespace Generics public void F1(int i) { Console.WriteLine("F1_int"); return; } // members with the same signature static void Main() g1a.F1(3); |
Hi,
Puzzled... really puzzled...
I wonder which function would govern? IMO, it would be the void F1(int i)...
But I guess it becomes a guessing game...
could you post it as a suggestion or bug?
http://lab.msdn.microsoft.com/productfeedback/
And please keep us posted...
cheers,
Paul June A. Domag
This works because the design has changed. According to a newsgroup post back in early april by Rick Byers (msft):, The behavior has indeed changed. You can expect the final version of the C# 2.0 spec to describe the behavior you are seeing. The C# team has made a number of changes to their internal copy of the spec (including this), but as far as I know it has not been released publicly since June 2004. Thanks, Rick If you look at the intellisense menus when trying out those overloads, you'll see that if parameters match, you'll get only 1 method whereas if you use a different type, you'll get two overloads. This is really great that they allowed generic overloads, and while it's not quite the same as partial specialization, it's a step in the right direction. It's very possible that you might want to have special handling of a function for a particular type, and this new behavior allows that. --Oren Oren, Saw Rick's post and it's blog http://blogs.msdn.com/rmbyers/archive/2005/02/16/375079.aspx. The latest specs (ECMA final draft published April 2005 - http://www.plumhall.com/ecma/index.html) shows a tiny sample that illustrates this new behavior, and also clearly states that non generics parameters take precedence over generics when selecting the "best method". Thanks for sharing. Willy
The behavior has indeed changed. You can expect the final version of the Thanks,
C# 2.0 spec to describe the behavior you are seeing. The C# team has made
a number of changes to their internal copy of the spec (including this),
but as far as I know it has not been released publicly since June 2004.
Rick
If you look at the intellisense menus when trying out those overloads, you'll see that if parameters match, you'll get only 1 method whereas if you use a different type, you'll get two overloads.
This is really great that they allowed generic overloads, and while it's not quite the same as partial specialization, it's a step in the right direction. It's very possible that you might want to have special handling of a function for a particular type, and this new behavior allows that.
--Oren