简体   繁体   English

C# 中的 System.Collections.Generic.List`1[System.Char]

[英]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.

相关问题 C# SelectMany 错误“无法隐式转换类型‘System.Collections.Generic.List<char> ' 到 'System.Collections.Generic.List<list> ’”</list></char> - C# SelectMany error " Cannot Implicitly convert type 'System.Collections.Generic.List<char>' to 'System.Collections.Generic.List<List>' " C#:无法隐式转换类型“System.Collections.Generic.List”<char> &#39; 到 &#39;System.Collections.Generic.List<string> &#39; - C#: Cannot implicitly convert type 'System.Collections.Generic.List<char>' to 'System.Collections.Generic.List<string>' C# System.Collections.Generic.List 中的错误<T> ? - Bug in C# System.Collections.Generic.List<T>? mysql = System.Collections.Generic.List中的C#结果 - c# result in mysql = System.Collections.Generic.List Cannot convert type 'System.Collections.Generic.List&lt; &gt;' to 'System.Collections.Generic.IList&lt; &gt;' c# MongoDB - Cannot convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >' c# MongoDB 无法隐式转换类型System.Collections.Generic.List <char> - cannot implicitly convert type System.Collections.Generic.List<char> C# LINQ - 道具字符串的值为 System.Collections.Generic.List`1[System.String] - C# LINQ - Prop string has value of System.Collections.Generic.List`1[System.String] 新手:C#列表返回System.Collections.Generic.List - Newbie: C# List returns back System.Collections.Generic.List C# 反思:如何获取List<employee> 而不是 System.Collections.Generic.List`1[Employee]?</employee> - C# Reflection: how to get List<Employee> instead of System.Collections.Generic.List`1[Employee]? 无法隐式转换类型&#39;System.Collections.Generic.List <AnonymousType#1> &#39;到&#39;System.Collections.Generic.List <Model.Common.Province> &#39;l C#MVc - Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<Model.Common.Province>'l C# MVc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM