a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
28 lines
617 B
C#
28 lines
617 B
C#
|
|
// Tests variable type inference with the var keyword when using the foreach statement with generic collections
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
public class Test
|
|
{
|
|
public static int Main ()
|
|
{
|
|
string[] strings = new string[] { "Foo", "Bar", "Baz" };
|
|
|
|
foreach (var v in strings)
|
|
if (v.GetType () != typeof (string))
|
|
return 1;
|
|
|
|
Dictionary<int, string> dict = new Dictionary<int, string> ();
|
|
dict.Add (0, "boo");
|
|
dict.Add (1, "far");
|
|
dict.Add (2, "faz");
|
|
|
|
foreach (var v in dict)
|
|
if (v.GetType () != typeof (KeyValuePair<int, string>))
|
|
return 2;
|
|
|
|
return 0;
|
|
}
|
|
}
|