[英]System.Collections.Generic.List`1[System.Char] in C#
I tried to get a value from Excel loaded for Timeout.我试图从为超时加载的 Excel 中获取一个值。
I used:我用了:
var Timeout = rows[i]["Timeout"].ToString().ToList();
But I'm getting System.Collections.Generic.List
1[System.Char]` instead of the values但我得到
System.Collections.Generic.List
1[System.Char]` 而不是值
You are getting你得到
System.Collections.Generic.List`1[System.Char]
System.Collections.Generic.List`1[System.Char]
as a result because you are calling ToList()
on a string
.结果是因为您在
string
上调用ToList()
。 Calling ToList()
on a string will give you each character of the string in form of a List<char>
.对字符串调用
ToList()
将以List<char>
形式为您提供字符串的每个字符。
My guess is that you are calling this line我的猜测是你正在打电话给这条线
var Timeout = rows[i]["Timeout"].ToString().ToList();
inside of a for-loop.在 for 循环内部。 In this case I think what you want is getting the Timeout column for reach row.
在这种情况下,我认为您想要的是获取到达行的超时列。 This can be achieved in the following way:
这可以通过以下方式实现:
var timeouts = new List<string>();
for(var i = 0; i < rowCount;i++)
{
timeouts.Add(rows[i]["Timeout"].ToString());
}
Now timeouts
will contain the values for the Timeout column for each row.现在
timeouts
将包含每行的Timeout列的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.