日期:2014-05-20  浏览次数:20832 次

LINQ中我要查询以什么开头。怎么做?
LINQ中我要查询以什么开头。怎么做?

string[] xx={"ABCEFG","ABCASDFASDF","12312ADSFASD"};

我想查询所有以ABC开头的字符串 怎么做?

------解决方案--------------------
C# code

void Main()
{
    string[] xx={"ABCEFG","ABCASDFASDF","12312ADSFASD"};
    xx.Where(x=>x.StartsWith("ABC")).ToList().ForEach(x=>Console.WriteLine(x));
    
    /*
    ABCEFG
ABCASDFASDF

    */
}