Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Strinq
- {
- public IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> seq, string property)
- {
- var prop = typeof(TSource).GetProperty(property);
- return seq.Select(s => prop.GetValue(s)).Cast<TResult>();
- }
- public IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> seq, string property, TSource value)
- {
- var prop = typeof(TSource).GetProperty(property);
- return seq.Where(s => Object.Equals(s, (TSource)prop.GetValue(s)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment