相关疑难解决方法(0)

如何在不使用foreach的情况下将ArrayList转换为强类型通用列表?

请参阅下面的代码示例.我需要ArrayList一个通用列表.我不想用foreach.

ArrayList arrayList = GetArrayListOfInts();  
List<int> intList = new List<int>();  

//Can this foreach be condensed into one line?  
foreach (int number in arrayList)  
{  
    intList.Add(number);  
}  
return intList;    
Run Code Online (Sandbox Code Playgroud)

.net c# list arraylist generic-list

56
推荐指数
2
解决办法
5万
查看次数

标签 统计

.net ×1

arraylist ×1

c# ×1

generic-list ×1

list ×1