a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
23 lines
495 B
C#
23 lines
495 B
C#
|
|
// Tests variable type inference with the var keyword when using the foreach statement with an array
|
|
using System;
|
|
using System.Collections;
|
|
|
|
public class Test
|
|
{
|
|
public static int Main ()
|
|
{
|
|
string [] strings = new string [] { "Foo", "Bar", "Baz" };
|
|
foreach (var item in strings)
|
|
if (item.GetType() != typeof (string))
|
|
return 1;
|
|
|
|
int [] ints = new int [] { 2, 4, 8, 16, 42 };
|
|
foreach (var item in ints)
|
|
if (item.GetType() != typeof (int))
|
|
return 2;
|
|
|
|
return 0;
|
|
}
|
|
}
|