Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int TEST_AMOUNT = 1;
- var arr = new int[TEST_AMOUNT];
- for (int i = 0; i < arr.Length; i++) arr[i] = i + 1;
- var testList = new List<int>();
- var s = new Stopwatch();
- s.Start ();
- foreach (int i in arr) {
- if (i % 3 == 0) testList.Add (i);
- }
- s.Stop (
- Console.WriteLine ("Foreach:\t{0} ticks", s.ElapsedTicks);
- s.Restart ();
- var testLinq =
- from i in arr
- where i % 3 == 0
- select i;
- s.Stop ();
- Console.WriteLine ("Linq:\t\t{0} ticks", s.ElapsedTicks);
Add Comment
Please, Sign In to add comment