Click here to Skip to main content
12,069,450 members (69,255 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

2.2K views
Posted

Few extension methods of IEnumerable in C#

, 18 Jul 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
The codepublic static IEnumerable IfMatchWith(this IEnumerable myList, string itemToMatch){ foreach (var item in myList.Where(item => item == itemToMatch)) yield return item;}could be rewritten as:public static IEnumerable IfMatchWith(this...
The code
public static IEnumerable<string> IfMatchWith(this IEnumerable<string> myList, string itemToMatch)
{
    foreach (var item in myList.Where(item => item == itemToMatch))
        yield return item;
}

could be rewritten as:

public static IEnumerable<string> IfMatchWith(this IEnumerable<string> myList, string itemToMatch)
{
    return myList.Where(item => item == itemToMatch);
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SergeyT2
Software Developer
Russian Federation Russian Federation
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160208.1 | Last Updated 18 Jul 2011
Article Copyright 2011 by SergeyT2
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid