-1
我有这样的代码:如何向列表开始的列表添加字符串?
for (int i = 0; i < Maps.Count; i++)
{
string startTag = FirstTags[i];
string endTag = LastTags[i];
startIndex = Maps[i].IndexOf(startTag);
while (startIndex > 0)
{
endIndex = Maps[i].IndexOf(endTag, startIndex);
if (endIndex == -1)
{
break;
}
string t = Maps[i].Substring(startIndex, endIndex - startIndex + endTag.Length);
if (i == 0)
{
imagesSatelliteUrls.Add(t);
}
position = endIndex + endTag.Length;
startIndex = Maps[i].IndexOf(startTag, position);
}
imagesSatelliteUrls = imagesSatelliteUrls.OrderBy(q => q).ToList();
所以第itertion /环路I = 0 然后其进入一个while循环。 然后我做:
if (i == 0)
{
imagesSatelliteUrls.Add(t);
}
那么到底imagesSatelliteUrls包含9个文件。 我想添加另一个索引到imagesSatelliteUrls列表的开头。 索引0的字符串将是例如:“组1” 然后其余9索引将是文件。
但是,我如何只添加一次,并在列表的开始字符串:“组1”? 那么到底该名单应该是这样的:
index[0] "Group 1"
index[1] file 1
index[2] file 2
.
.
.
.
index[9] file 9
所以我知道,“组1”是从1到9
找到你需要的任何地方[这里](http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx) – BartoszKP
使用插入方法与0索引 – saeed