Let's say we have a variable of type IEnumerable<T> and we want to cast it into an array.
Resharper has suggested my a snippet like this:
var collection = input as T[] ?? input.ToArray()
Is there any chance in which input as T[] returns null so that the input.ToArray() part comes to action? Even if that occurs, why wouldn't we directly use the extension method instead of that? like this:
var collection = input.ToArray();
What is the difference between casting through calling ToArray extension method and using as operator?