Chintan Dave

Chintan Dave

  • NA
  • 67
  • 35k

Instance of Interface in C#

Aug 29 2018 4:34 AM
I have searched through internet that can we create instance of Interface or not , the answer that I receive is no.
 
Reference Link:
 
https://www.google.co.in/search?q=can+we+create+object+of+interface+in+c%23&oq=can+we+create+object+of+interface&aqs=chrome.2.69i57j0l5.10169j0j7&sourceid=chrome&ie=UTF-8
 
Then I find one article on C-sharpCorner site which comprises lines of code like below:
 
IEnumerable<string> iEnumerableOfString = (IEnumerable<string>)Month;
IEnumerator<string> iEnumeratorOfString = Month.GetEnumerator();
 
Reference Link :
 
https://www.c-sharpcorner.com/UploadFile/219d4d/ienumerable-vs-ienumerator-in-C-Sharp/
 
Question: As per my knowledge, IEnumerable and IEumerator both are interfaces then how are we able to create instances of both mentioned in the above article?

Answers (1)