C# allows creating and populating multidimensional arrays, here is a simple example:
    public static void Main(String[] args)
    {
        var arr = (int[,])CreateArray(new [] {2, 3}, 8);
        Console.WriteLine("Value: " + arr[0,0]);
    }
    // Creates a multidimensional array with the given dimensions, and assigns the
    // given x to the first array element
    public static Array CreateArray<T>(int[] dimLengths, T x)
    {
        var arr = Array.CreateInstance(typeof(T), dimLengths);
        var indices = new int[dimLengths.Length];
        for (var i = 0; i < indices.Length; i++)
            indices[i] = 0;
        arr.SetValue(x, indices);  // Does boxing/unboxing
        return arr;
    }
This works well. However, for some reason there is no generic version of Array.SetValue(), so the code above does boxing/unboxing, which I'd like to avoid. I was wondering if I missed something or if this is an omission in the .NET API?

forloop is unnecessary. A new array is guaranteed to be initialized upon creation. Sonew int[L]makes an array filled withdefault(int)which is0.int[,] arr = new int[2, 3]; arr[0, 0] = 8;, will the value8be boxed? I guess not. Will check next time I come by a C# compiler, from the resulting IL.