I have written the following code to print the item values inside the list. Now I want to measure which one is faster as going forward I will have huge list to deal with. And please specify why you think that's better (if any evidences)
So how do I calculate the processing time? Is manually creating a bulky List is the only option?
public void printMedod(string strPrintListVal)
{
Console.WriteLine(strPrintListVal);
}
static void Main(string[] args)
{
Program p1 = new Program();
List<string> listString = new List<string> { "Rox","Stephens","Manahat","Lexus",":)"};
listString.ForEach(p1.printMedod);
Console.ReadKey();
}
I can also do the same thing using GetEnumerator:
static void Main(string[] args)
{
List<string> listString = new List<string> { "Rox","Stephens","Manahat","Lexus",":)"};
var enumerator = listString.GetEnumerator();
while (enumerator.MoveNext())
{
var pair = enumerator.Current;
Console.WriteLine(pair);
}
Console.ReadKey();
}