BoolDictionary
Use the BoolDictionary
type to map string values to Boolean values. This example shows how you use a BoolDictionary
type to ensure that accounts are processed only once:
void AccountsDemo()
{
BoolDictionary accounts = CreateBoolDictionary();
accounts["Bob"] = true; // Has been processed.
accounts["Alice"] = false; // Has not been processed.
ProcessAccount(accounts, "Bob");
ProcessAccount(accounts, "Alice");
}
void ProcessAccount(BoolDictionary accounts, string accountId)
{
if (!accounts[accountId])
{
WriteLine("Processing " + accountId);
accounts[accountId] = true;
}
}