tags:

views:

152

answers:

2
public delegate T GetObject<T>(SqlDataReader reader);
public delegate KeyValuePair<TKey, TValue> GetObject<TKey, TValue>(SqlDataReader reader);

Is it possible for removing that 2nd line (the two lines are on consecutive lines) to ever make any difference at all, superficial or not?

+1  A: 

Absolutely - anything which is trying to declare a value of type GetObject<string,string> will fail to compile, for example.

Now, you can certainly replace any use of GetObject<TKey,TValue> with GetObject<KeyValuePair<TKey,TValue>> (if you see what I mean) but you can't just remove the second line.

You should also be careful of the case where this is used by reflection. It may well not be a problem in your case, but it's an easy way for a breaking change to only be visible at execution time rather than being picked up by the compiler.

Jon Skeet
+1  A: 

Can it make a difference. Most definitely. Removing this delegate definition will cause the formerly valid code to be a compilation error.

var x = new GetObject<int,String>(SomeFunction);
JaredPar