3 ms·
> in this circumstance C# lets you write many methods, use generics, or (now I believe) use dynamically typed variables. Or you could be explicit about the int
by DougBTX 16y ago
> in this circumstance C# lets you write many methods, use generics, or (now I believe) use dynamically typed variables.
Or you could be explicit about the interface you are writing the duck-typed code against. The problem here is that you can't assign an interface to an existing type, and adding interface declarations results in more code. It will be interesting to see whether this functionality (extension interfaces and inferred interfaces) makes it into C# in the next 5 years. My guess is that it's functionality which is possible to add, but we're not there yet.