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
argumentactually is aT[], or throw anInvalidCastExceptionexception if it isn’t. (Or return null ifargumentis null.)