DoubleDictionary

Use the DoubleDictionary type to map string values to double values. This example shows how you use a DoubleDictionary type to manage a list of accounts:

void AccountsDemo()
{
	DoubleDictionary accounts = CreateDoubleDictionary();
	accounts["Bob"] = 2123.12;
	accounts["Alice"] = -101.5;

	AddToAccount(accounts, "Bob", 100);
	AddToAccount(accounts, "Alice", -100);

	foreach (string customerName in Keys(accounts))
	{
		WriteLine(customerName + ": " + accounts[customerName]);
	}
}
void AddToAccount(DoubleDictionary accounts, string customer, double amount)
{
	if (!ContainsKey(accounts, customer))
	{
		accounts[customer] = 0;
	}
	accounts[customer] = accounts[customer] + amount;
}