附加一个列表内容到另一个列表C# [英] Append a Lists Contents to another List C#
本文介绍了附加一个列表内容到另一个列表C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下内容:
- 系统主列表,名为GlobalStrings
- 另一个列表,名为localStrings
在例如一个循环
GlobalStrings =新的List<串GT;();
为(X = 1; X小于10; X ++)
{
localStrings =新的List<字符串取代;
localStrings.Add(某些价值);
localStrings.Add(某些价值); //要尽可能容易地追加到localStrings GlobalStrings
}
解决方案
GlobalStrings.AddRange(localStrings);
请注意:使用接口(IList的)你不能声明列表对象
I have the following:
- A main List called GlobalStrings
- Another List called localStrings
In a loop for example:
GlobalStrings = new List<string>();
for(x=1;x<10;x++)
{
localStrings = new List<string>;
localStrings.Add("some value");
localStrings.Add("some value");
// Want to append localStrings to GlobalStrings as easily as possible
}
解决方案
GlobalStrings.AddRange(localStrings);
Note: You cannot declare the list object using the interface (IList).
这篇关于附加一个列表内容到另一个列表C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文