update readme (#21797)
[mono-project.git] / mcs / tests / test-var-03.cs
blob7df159597406e4ae2480b059d87b0a6b73323d58
2 // Tests variable type inference with the var keyword when using the foreach statement with an array
3 using System;
4 using System.Collections;
6 public class Test
8 public static int Main ()
10 string [] strings = new string [] { "Foo", "Bar", "Baz" };
11 foreach (var item in strings)
12 if (item.GetType() != typeof (string))
13 return 1;
15 int [] ints = new int [] { 2, 4, 8, 16, 42 };
16 foreach (var item in ints)
17 if (item.GetType() != typeof (int))
18 return 2;
20 return 0;