本文整理汇总了C#中HashMap.ContainsValue方法的典型用法代码示例。如果您正苦于以下问题:C# HashMap.ContainsValue方法的具体用法?C# HashMap.ContainsValue怎么用?C# HashMap.ContainsValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashMap
的用法示例。
在下文中一共展示了HashMap.ContainsValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
IMap<string, int> map = new HashMap<string, int>();
map.Put("yellow", 1);
map.Put("blue", 10);
map.Put("red", 67);
while(true)
{
string[] command = Console.ReadLine().Split(' ');
try
{
switch (command[0].ToLower())
{
case "clear":
map.Clear();
break;
case "put":
map.Put(command[1], Convert.ToInt32(command[2]));
break;
case "remove":
map.Remove(command[1]);
break;
case "containskey":
Console.WriteLine(map.ContainsKey(command[1]));
break;
case "containsvalue":
Console.WriteLine(map.ContainsValue(Convert.ToInt32(command[1])));
break;
case "list":
foreach (IEntry<string, int> e in map)
Console.WriteLine(e.ToString());
break;
case "keys":
foreach (string s in map.Keys)
Console.WriteLine(s);
break;
case "values":
foreach (int i in map.Values)
Console.WriteLine(i.ToString());
break;
case "testum": //test
UnmutableMap<string, int> um = new UnmutableMap<string, int>(map);
Console.WriteLine(um["red"].ToString());
um["red"] = 3;
break;
case "testfind":
map = MapUtilsGeneric<string, int>.FindAll(map,
new MapUtilsGeneric<string, int>.CheckDelegate( (Entry<string, int> e) => { return e.Key[0] == 'r'; } ),
MapUtilsGeneric<string, int>.ArrayMapConstructor);
break;
default:
throw new Exception("Unknown command.");
}
} catch (Exception ex)
{
Console.WriteLine(ex.GetType().ToString() + ": " + ex.Message);
}
}
}