Items - Add / Remove
Counting Occurrences
System.Collections.Generic.Dictionary<string, int> MyDictionary;
MyDictionary = new System.Collections.Generic.Dictionary<string, int>();
public static Dictionary_Counting_Add(
System.Collections.Generic.Dictionary<string, int> MyDictionary,
string myItem)
{
int counter;
try
{
if (MyDictionary.ContainsKey(myItem) == false)
{
counter = 1;
MyDictionary.Add(myItem, counter);
}
else
{
counter = MyDictionary[myItem];
MyDictionary[myItem] = counter++;
}
}
catch (System.Exception ex)
{
}
}
public static Dictionary_Counting_FindMax(
System.Collections.Generic.Dictionary<string, int> MyDictionary)
{
int occurrences_max;
int occurrences;
string myTopItem;
try
{
for (int icount = 0; icount < MyDictionary.Count; icount++)
{
occurrences = MyDictionary.ElementAt(icount).Value
if (occurrences > occurrences_max)
{
occurrences_max = occurrences;
myTopItem = MyDictionary.ElementAt(icount).Key
}
}
return myTopItem;
}
catch (System.Exception ex)
{
}
}
Group of Strings
System.Collections.Generic.Dictionary<string, string> dicForFastAccess;
dicAuthors = new System.Collections.Generic.Dictionary<string, string>();
dicForFastAccess.Add(key, value);
dicForFastAccess.Add("001", "my first string");
dicForFastAccess.Add("002", "my second string");
Group of Arrays
System.Collections.Generic.Dictionary<string, string[]> dicForStoringArrays;
dicForStoringArrays = new System.Collections.Generic.Dictionary<string, string[]>();
dicForStoringArrays.Add(key,value);
dicForStoringArrays.Add("Item1", ??);
Removing
dicAuthors.Remove(key)
dicAuthors.Remove("001")
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext