Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Maintaining collection
Message
De
23/05/2013 08:42:15
 
 
À
23/05/2013 06:25:32
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01574508
Message ID:
01574569
Vues:
42
>You can update the value of a dictionary
>
>Here, I use a Tuple of three integers - for simplicity the first one is the key
>
>
>
>		public static void Main()
>		{
>
>
>			Dictionary<int, Tuple<int, int, int>> dict = new Dictionary<int, Tuple<int, int, int>>();
>
>			Tuple<int, int, int> t;  // key is tuple.Item1
>
>			t = new Tuple<int, int, int>(1, 1, 1);
>			UpdateDictionary(dict, t);
>
>			t = new Tuple<int, int, int>(2, 1, 1);
>			UpdateDictionary(dict, t);
>
>			PrintDictionary("Before any update", dict);
>
>			t = new Tuple<int, int, int>(2, 2, 2);
>			UpdateDictionary(dict, t);
>
>			PrintDictionary("After update", dict);
>			Console.ReadLine();
>		}
>		static void UpdateDictionary(Dictionary<int, Tuple<int, int, int>> dict, Tuple<int, int, int> t)
>		{
>			if (dict.ContainsKey(t.Item1) )
>			{
>				dict[t.Item1] = t;
>			}
>			else
>				dict.Add(t.Item1, t);
>		}
>		static void PrintDictionary(string msg, Dictionary<int, Tuple<int, int, int>> dict)
>		{
>			Console.WriteLine(msg);
>			foreach (KeyValuePair<int, Tuple<int, int, int>> x in dict)
>			{
>				Console.WriteLine("{0} {1} {2}", x.Value.Item1, x.Value.Item2, x.Value.Item3);
>			}
>
>		}
>
Thanks, this is interesting.

I ended up building a class of my own which I can make evolve in any way I wish. I use basically a dataset with rows, by the use using of passing a primary key with the field name and values. I can then manipulate that in the same way I manipulate data from the database.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform