check for any item in string array?

Total Post:30


C#  Array 
 1359  View(s)
Rate this:
static void Main(string[] args)
    if (args[0].ToUpper().Equals("DOWNLOADPOS"))

will run DownloadPOS(), if the first item in args is downloadpos, I would like to check against all the items in args?? please advise? 

I was previously using: 

//if (args.Contains(pos))


//    DownloadPOS();


but then wasnt sure how to sure the upper on it 


  1. Re: check for any item in string array?

    if (arg.Any(x => x.Equals("DOWNLOADPOS",StringComparison.OrdinalIgnoreCase)))

    If you need to support special cultures (e.g. Turkish), use StringComparison.InvariantCultureIgnoreCase instead of StringComparison.OrdinalIgnoreCase

      Modified On Apr-07-2018 05:33:22 AM
  1. Re: check for any item in string array?

    You can use Linq, Enumerable.Any Method Method

    var exist = args.Any(x =>x.ToUpper().Equals("DOWNLOADPOS"));
    if (exist)

      Modified On Apr-07-2018 05:33:07 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.