class Class1
{
public virtual void Update(T entity)
{
Update(new List() { entity }); //It\'s failed
}
public virtual void
You are essentially asking why the compiler is not creating an implicit cast from List
to IEnumerable
. The reason is that the C# team made a deliberate design decision that cases of potential ambiguity must be resolved by the programmer, not the compiler. (Note that the VB.NET team made a different decision, to always attempt something sensible that is consistent with the perceived programmer intent.)
The advantages in a case such as this are that surprise is minimized - nothing unexpected can happen under the covers; the disadvantage is the occasional need for more verbose code.