获取一个包含C#中ListDictionary中的值的ICollection
要获取包含ListDictionary中的值的ICollection,代码如下-
示例
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main(){
ListDictionary listDict = new ListDictionary();
listDict.Add("1", "Laptop");
listDict.Add("2", "Tablet");
listDict.Add("3", "Desktop");
listDict.Add("4", "Speaker");
listDict.Add("5", "Earphone");
listDict.Add("6", "Headphone");
ICollection col = listDict.Values;
foreach(String s in col){
Console.WriteLine(s);
}
}
}输出结果
这将产生以下输出-
Laptop Tablet Desktop Speaker Earphone Headphone
示例
让我们看另一个例子-
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main(){
ListDictionary listDict = new ListDictionary();
listDict.Add("A", "Tom");
listDict.Add("B", "John");
listDict.Add("C", "Kevin");
listDict.Add("D", "Tim");
ICollection col = listDict.Values;
foreach(String s in col){
Console.WriteLine(s);
}
}
}输出结果
这将产生以下输出-
Tom John Kevin Tim
热门推荐
1 祝福语简短七夕
10 新老师祝福语 简短独特
11 给老人的祝福语简短
12 中班入学祝福语简短大全
13 送师姐的祝福语简短
14 舅舅大婚文案祝福语简短
15 简短的高考祝福语精选
16 薛之谦祝福语简短
17 给老板祝福语简短精辟
18 保持快乐祝福语大全简短