コード
using System;
using System.Linq;
using System.Collections.Generic;
public class IEnumerableTest
{
public static void Main()
{
int [,] ary = new int[3, 3] {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
foreach(var x in ary.Cast<int>())
{
Console.WriteLine(x);
}
}
}
出力結果
1
2
3
4
5
6
7
8
9
ちなみに
var xs = new int[3, 3]{ ... };
とかした後に
xs[1]
とかすると
IEnumerable.cs(14,30): error CS0022: Wrong number of indexes1' inside [], expected
2'
と怒られます。