C#C
C#14mo ago
tommy

✅ Difference between `string[]` and `IEnumerable<string>`

in the following the code, the output seems to be the same:
using System;
using System.IO;

class Program
{
  public static void Main()
  {
    foreach (string dir in Directory.GetDirectories("Settings"))
      Console.WriteLine(dir);
    
    foreach (string dir in Directory.EnumerateDirectories("Settings"))
      Console.WriteLine(dir);
  }
}


i know that
enum
s are used to define a set of exhaustive types, and are closely related to
int
s.
but what does it mean to have
IEnumerable<string>
and how different is it from
string[]
?
Was this page helpful?