【发布时间】:2016-08-11 04:46:56
【问题描述】:
我有两个列表
- 字符串的嵌套列表,并且
- 字符串列表
在index 列表中,我想添加带有common 值的linesOfContent,在两者之间我想添加单独的字符串":"。
为此,我编写了一个代码,但是,我遇到了一个问题“无法从 'string' 转换为 'system.collections.generic.list string'”。如何解决这个问题。
int common = 10;
List<List<string>> index = new List<List<string>>();
List<int> linesOfContent = new List<int>();
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++)
{
linesOfContent.Add(i+":"+common);
}
index.Add(linesOfContent);
}
预期输出:
index[0][0] = 0:10
index[0][1] = 1:10
index[0][2] = 2:10
... ...
【问题讨论】:
-
你能在
indexList 中显示预期的结果吗? -
@shad0wk 我想要一个符合预期输出的结果。
标签: c# string list typeconverter