C# KeyValuePair TKey,TValue的用法
在C#中,KeyValuePair
以下是KeyValuePair
KeyValuePair pair = new KeyValuePair("Key", 123); string key = pair.Key;
int value = pair.Value;pair = new KeyValuePair("NewKey", 456); public KeyValuePair GetKeyValuePair()
{
return new KeyValuePair("Key", 123);
}
public void ProcessKeyValuePair(KeyValuePair pair)
{
// 处理键值对
} Dictionary dictionary = new Dictionary();
// 添加键值对到字典
foreach (KeyValuePair pair in dictionary)
{
string key = pair.Key;
int value = pair.Value;
// 处理键值对
} 总而言之,KeyValuePair
TOP