简体   繁体   English

如何从 System.Collections.Generic.IEnumerable 转换<char> ' 到 C# 中的 'char[]'</char>

[英]how to convert from System.Collections.Generic.IEnumerable<char>' to 'char[]' in C#

//CS0266 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'char[]'. //CS0266 无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“char[]”。

   foreach(string newstr in Reversewords)
    {
       var strArr = newstr.ToCharArray();
        char[] chaArr= strArr.Reverse(); // error in this line
        sb.Append(chaArr);
    }

I think you shuold do this in other way, you can first, turn it to string.我认为您应该以其他方式执行此操作,您可以先将其转换为字符串。

Also you can find some intresting things about this here: IEnumerable<char> to string你也可以在这里找到一些有趣的东西: IEnumerable<char> to string

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从&#39;System.Collections.Generic.IEnumerable转换 <char> &#39;到&#39;字符串&#39; - cannot convert from 'System.Collections.Generic.IEnumerable<char>' to 'string' 无法从&#39;System.Collections.Generic.IEnumerable转换 <System.Collection.Generic.List<char> &gt;字符串[] - Cannot convert from 'System.Collections.Generic.IEnumerable<System.Collection.Generic.List<char>> to string[] C#,无法从“ System.Collections.Generic.IEnumerable”转换为“ string []” - C#, cannot convert from 'System.Collections.Generic.IEnumerable' to 'string[]' 无法隐式转换类型&#39;System.Collections.Generic.IEnumerable <char> “ to”字符串 - Cannot implicit convert type 'System.Collections.Generic.IEnumerable<char>'to'string CS0266 无法隐式转换类型 'System.Collections.Generic.IEnumerable<char> '到'字符串'</char> - CS0266 cannot implicitly convert type 'System.Collections.Generic.IEnumerable<char>' to 'string' TreeView:无法从&#39;System.Collections.Generic.IEnumerable转换 <string> &#39;到&#39;System.Collections.Generic.IEnumerable - TreeView: Cannot convert from 'System.Collections.Generic.IEnumerable<string>' to 'System.Collections.Generic.IEnumerable 无法从&#39;System.Collections.Generic.IEnumerable转换为System.Collections.Generic.IEnumerable <string> - Cannot convert from 'System.Collections.Generic.IEnumerable to System.Collections.Generic.IEnumerable<string> 无法从&#39;System.Collections.Generic.IEnumerable转换 <int> &#39;到&#39;System.Collections.Generic.IEnumerable <int?> “ - Cannot convert from 'System.Collections.Generic.IEnumerable<int>' to 'System.Collections.Generic.IEnumerable<int?>' 无法从“ System.Collections.Generic.IEnumerable”转换为System.Collections.Generic.IEnumerable <string> - cannot convert from 'System.Collections.Generic.IEnumerable' to System.Collections.Generic.IEnumerable<string> 如何转换类型&#39;System.Collections.Generic.IEnumerable <AnonymousType#1> &#39;到&#39;System.Collections.Generic.IEnumerable &lt;&gt;&#39;。 - how to convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to 'System.Collections.Generic.IEnumerable<>'.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM