views:

54

answers:

2

I'm implementing some networking code using the selector pattern in C# / .NET 3.5. However, I was surprised to find that the Select method takes nongeneric IList's rather than IList<Socket>'s. It says clearly in the help documentation though that a list of sockets is expected here and nothing else.

Does anyone know why this is the case?

+2  A: 

Socket.Select (which I assume you mean by Select) is a method that was already present in .NET 1.0, and Microsoft apparently never bothered to update it, probably because it is a quaint and seldom-used API.

ErikHeemskerk
How could they have updated it anyway?
Jon Skeet
Provide an overload and decorate the original function with `ObsoleteAttribute`.
ErikHeemskerk
+2  A: 

From the docs:

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

That would have been a pretty interesting signature in .NET 1.0...

The signature can't be changed without breaking existing callers. They could have added an overload, but I'm not sure it would have helped very much - if you'd tried to use the "new" overload with the wrong argument types (e.g. List<string> instead of List<Socket>) it would just have bound to the old overload.

Jon Skeet
Thanks. The explanation about why they couldn't just have added an additional overload is what I was missing.
David Pfeffer