I have a method that looks like:
T[] field;
public Method(IList<T> argument)
{
this.field = (T[])argument;
}
When the body of the method is executed does enumeration take place during the cast? Would that change if the underlying type was different?
No, it won't enumerate anything. It will either succeed if argument
actually is a T[]
, or throw an InvalidCastException
exception if it isn't. (Or return null if argument
is null.)