By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

C# 2.0 spec: generics and invalid overloads

P: n/a
According to the C# 2.0 draft spec, the following should not compile:

class G1<U>
{
long F1(U u) {return 0;} // Invalid overload, G<int> would have two
int F1(int i){return 1;} // members with the same signature
}

However, it compiles without error or warning for me. This also compiles
clean:

class G1<U>
{
int F1(U u) {return 0;} // Invalid overload, G<int> would have two
int F1(int i){return 1;} // members with the same signature
}

Did the spec change on this? Is this now allowed? The version of the
spec that I downloaded was from May 2004.

FWIW, compiler version is
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727

H^2

Mar 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Harold Howe wrote:
According to the C# 2.0 draft spec, the following should not compile:

class G1<U>
{
long F1(U u) {return 0;} // Invalid overload, G<int> would have two
int F1(int i){return 1;} // members with the same signature
}

However, it compiles without error or warning for me. This also compiles
clean:

class G1<U>
{
int F1(U u) {return 0;} // Invalid overload, G<int> would have two
int F1(int i){return 1;} // members with the same signature
}

Did the spec change on this? Is this now allowed? The version of the
spec that I downloaded was from May 2004.

FWIW, compiler version is
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727


See section 20.1.8 of the currrent C# language specification 2.0 in the
March 2005 draft available from
http://download.microsoft.com/downlo...cification.doc.
Basically it is valid and will be resolved to the non-generic overload of
the method.
--
Tom Porterfield

Mar 28 '06 #2

P: n/a
See section 20.1.8 of the currrent C# language specification 2.0 in the
March 2005 draft available from
http://download.microsoft.com/downlo...cification.doc.


That is exactly what I needed. Thank you very much.

H^2
Mar 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.