Skip
是LINQ的扩展方法。您必须在您的项目引用添加到System.Core
,并在情况下,它需要一个using System.Linq;
指令
编辑
正如你似乎是“无法”使用LINQ,这里是一个非LINQ的解决方案(就像重新发明轮子)的实验:
扩展方法
public static class ExtMeth
{
public static IEnumerable<string> SkipLines(this string[] s, int number)
{
for (int i = number; i < s.Length; i++)
{
yield return s[i];
}
}
public static string[] ToArray(this IEnumerable<string> source)
{
int count = 0;
string[] items = null;
foreach (string it in source)
{
count++;
}
int index = 0;
foreach (string item in source)
{
if (items == null)
{
items = new string[count];
}
items[index] = item;
index++;
}
if (count == 0) return new string[0];
return items;
}
}
使用方法
this.textBox1.Lines = this.textBox1.Lines.SkipLines(2).ToArray();
刚刚几分钟前你刚刚问过吗?添加'使用System.Linq;'到你的班级 – Pikoh
@Pikoh谢谢:)我删除了它,并带有一个新问题o显示我尝试过的代码。 “使用System.Linq”不起作用。同样的问题出现。 – user6203007
你有没有在'System.Core'的专家中参考?你有什么.NET平台的目标? – Pikoh