c# object[]

hi,
working in Java object array, c # does not work. researching for a long time, but I could not find anything. could you help me.

working in Java. working in c#:

obj["i"]

working in Java. c # does not work:

obj["i"]["i"]

thanks in advance…

It is JavaScript not Java - they are very different languages. In JavaScript there is the concept of an associative array - this is unusual in most programming languages where these different effects are created by using different collections.

You would use a Dictionary in C# if you want to have a string (or other associative) based key. For your seconds example you would have a Dictionary that contained a Dictionary.

using System.Collections.Generic;
Dictionary<string, Dictionary<string, object>> myAssociativeDictionary = new Dictionary<string, Dictionary<string,object>>();

You would normally use a specific class instead of object in the above example to avoid having to cast often on the result.

Try this

int i=2,j=2;
object[,] asd = new object[i,j];