【发布时间】:2020-12-23 07:27:59
【问题描述】:
我尝试删除超过 35 个字符的行,但出现此错误:
无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“string[]”。存在显式转换(您是否缺少演员表?)
我不知道如何解决它。谁能帮帮我?
我的代码:
var lines = File.ReadAllLines("my path");
lines = lines.Where(x => x.Length <= 35); // error is here
File.Delete("my path");
File.AppendAllLines("my path", lines);
【问题讨论】:
-
将鼠标悬停在代码中的
Where上并检查返回类型。请注意,它与lines的类型不同。 -
在发送您的问题之前搜索当前问题,不要搜索并讲述您的故事。
标签: c#