{
字典& ltstring,class 1 & gt;cl =新詞典& ltstring,class 1 & gt;();
class 1s 1 = new class 1("張三",25);
class 1 S2 = new class 1(" Lisi ",26);
Class1 s3 = new Class1("賈六",27);
cl。添加(s1。姓名,s 1);
cl。添加(s2。名字,S2);
cl。添加(s3。姓名,S3);
foreach(key value pair & lt;string,class 1 & gt;cl中的a)
{
MessageBox。show(a . value . age . tostring()+" "+a . value . name . tostring());
}
foreach(key value pair & lt;string,class 1 & gt;cl中的a)
{
if (a.Key == s1。姓名)
MessageBox。show(a . value . age . tostring()+" "+a . value . name . tostring());
}
}