vendredi 27 mars 2015

Check if characters are part of a String

I want to check if a set of characters are part of String variable are not, Ideally I would do one of the below,



  1. Store the characters in a list and loop through each character to check if they exist in the string.

  2. Form a simple if statement with OR operations in case the character set is small.


Is there a better way to do this, may be using LINQ.


As an example I want to check if any of the characters '>' or '<' or '=', are part of the string 'a > b and b != 10'.


Aucun commentaire:

Enregistrer un commentaire