Under MonoTouch the following line of code compiles, but generates an InvalidProgramException:
var bytes = new byte[,]{};
System.InvalidProgramException
Invalid IL code in Foo: IL_0038: newobj 0x0a000012
However, the following does not fail at runtime:
var bytes = new byte[,]{{}};
I am fine with using the second expression. But, is there anything wrong with the first? If so, shouldn’t it fail to compile?
This looks like it’s a bug in the C# compiler in MonoTouch, it compiles the expression incorrectly.
If I try with a newer C# compiler (from Mono 2.12), the expression is compiled correctly and the resulting program works.
The current plan is for MonoTouch to start using Mono 2.12 some time later this fall, if it is an blocker for you, you can open a bug report to see if a fix can make it into an earlier version of MonoTouch.