If we have written a class called MyClass
and need an object of it's type, we would go
var myVar = new MyClass();
and also if our MyClass
has an IEnumerable
interface we again need the new
keyword such as:
class myClass : IEnumerable {...}
var myVar = new MyClass();
what about a situation when our class, MyClass
is not used as one but as a type to instantiate a new variable of say:
IEnumerable<MyClass> myVar;
I would say we should clearly get an error if we go
IEnumerable<MyClass> myVar = new IEnumerable<MyClass>();
but trying to understand the logic behind this. How this enumeration set of objects get created in this situation?