Use of generic collections and Dictionary initializers

I’m having trouble with Unity’s C# parser choking on what should be valid syntax. I’m not very familiar with C#/.NET, so maybe this is a language level issue or something (is the C# ‘dialect’ in Unity current?)

For example, if I try to use a generic-typed Dictionary, Unity chokes:

MyClass example = new MyClass(
new Dictionary<string, object>());

results in:

error CS0122: `System.Collections.Generic.Dictionary<string,object>.Dictionary(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)’ is inaccessible due to its protection level

and if I try to do this:

MyClass example = new MyClass(
new Dictionary<string, object> {
{ “id”: 1 }, { “name”: “test” }
});

I get this:

error CS1526: A new expression requires () or [ ] after type

followed by several knock-on syntax errors. This code works fine outside of Unity (e.g. in MonoDevelop).

Does Unity implement an older version of C#/.NET? Is there an alternate syntax I can use to succinctly pass a set of name/value pairs into a constructor?

Thanks,

L.

Unity is Mono 1.2.5 so basically .NET 2.0 so your .NET 3+ code will not work. no lambda and inlines