C#: How to gracefully pass multiple conditions to Equals()

Posted by Roy on Stack Overflow See other posts from Stack Overflow or by Roy
Published on 2011-01-02T07:33:51Z Indexed on 2011/01/02 7:53 UTC
Read the original article Hit count: 233

Filed under:
|

I'm new to C#, and I'm trying to write a program that selects file types from a FileInfo list. So far I have something along the lines of:

    List<FileInfo> files = new List<FileInfo>();
    IEnumerable<FileInfo> result =  files.Where(f=>f.Extension.Equals(".jpg", StringComparison.InvariantCultureIgnoreCase)||
    f.Extension.Equals(".gif", StringComparison.InvariantCultureIgnoreCase) );

etc

Obviously I'm not happy with this solution, but I don't know how to do this otherwise in a single call.

What's the better way to go about it?

© Stack Overflow or respective owner

Related posts about c#

Related posts about equals