开发者

Condition in generic lists

开发者 https://www.devze.com 2023-02-06 08:27 出处:网络
I\'m wondering is there any condition instead of T-SQL like in generic lists in C# 4.0. I\'ve got a gridview on my 开发者_如何学Gopage I got all datas and I need to search by name and lastname, so I

I'm wondering is there any condition instead of T-SQL like in generic lists in C# 4.0.

I've got a gridview on my 开发者_如何学Gopage I got all datas and I need to search by name and lastname, so I think there must be but I couldn't find yet.


Use String.Contains, String.StartsWith or String.EndsWith as part of a predicate, either using List<T>.FindAll or Where in LINQ.

For example:

var jons = people
    .Where(p => p.FirstName.StartsWith("Jon", StringComparison.CurrentCultureIgnoreCase))
    .ToList();


Thats called Contains

0

精彩评论

暂无评论...
验证码 换一张
取 消