Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Array of indexers?
Message
De
25/07/2009 12:20:36
 
 
À
25/07/2009 05:38:11
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Divers
Thread ID:
01414024
Message ID:
01414486
Vues:
33
>>>I don't know whether my head is just not working right these days (keep your comments to yourself), or if it really is has hard as I'm making it for myself, but how do you deal with an array of indexers? What is the syntax for accessing the indexer values in an array of indexers?
>>>
>>>Thanks
>>
>>'S'ok. I figured it out. I seems you declare it like any other array, but you access it like a 2 dimensional array (I think).
>
>In fact, you're accessing them like jagged arrays ( http://msdn.microsoft.com/en-us/library/2s05feca.aspx )

Yes. I keep saying two dimension, but I actually meant jagged. So where were you before I hurt my brain figuring it out? ;)

>
>
>The 'indexers' are evaluated left to right
>
>
>	class Test
>	{
>		public static void Main()
>		{
>			// an array of lists that have dictionaries
>			var q = new List<Dictionary<string, int>>[] 
>			{
>				// q[0]
>				new List<Dictionary<string, int>> 
>					{ 
>						// q[0][0]
>						new Dictionary<string, int>
>						{
>							{ "george I", 1},
>							{ "alan I", 2},
>							{ "don I", 3}
>						},
>						// q[0][1]
>						new Dictionary<string, int>
>						{
>							{ "sam I", 1},
>							{ "pat I", 2}
>						}
>					},
>				// q[1]
>				new List<Dictionary<string, int>> 
>					{ 
>						// q[1][0]
>						new Dictionary<string, int>
>						{
>							{ "george II", 21},
>							{ "alan II", 22},
>							{ "don II", 23}
>						}
>					}
>			};
>
>			Console.WriteLine(" {0}", q[1][0]["alan II"]); //22 
>			Console.ReadLine();
>			
>		}
>	}
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform