While learning C# basics i have learned that foreach works on those collection that have implemented IEnumerable
interface. So far so good but today when I have came across DirectoryInfo
I got confused.
If DirectoryInfo
doesn't implement IEnumerable
, then how does it come that foreach
works?
DirectoryInfo[] dirListing = new DirectoryInfo(@"F:\eBook").GetDirectories();
foreach (DirectoryInfo dir in dirListing)
{
Console.WriteLine(dir.Name);
}
Please tell me.......