public class Start
{
public Start()
{
string[] arrayStrings = { "apple" ,"bmw" ,"cat", "dog", "Eagle" };
List<string> lstStrings = new List<string> () { "apple", "bmw", "cat", "dog", "Eagle" };
IList<string> IlstStrings = new List<string>() { "apple", "cat", "dog", "Eagle" };
PassCollectionOfStrings(arrayStrings);
PassCollectionOfStrings(lstStrings);
PassCollectionOfStrings(IlstStrings);
}
//By using ienumberable <T> , we can pass any type of collection
public void PassCollectionOfStrings (IEnumerable<string> collectionStrings)
{
foreach (string i in collectionStrings)
{
Console.WriteLine(i);
}
}
}