during parsing string I want to make decision when to stop and go to get next portion from string. My main goal is to take 3 portions of string 26 or less chars length. My code seems to me a little weird
for (basis=i*26; basis<name.Length
&& name[basis] != ' '
&& name[basis] != '-'
&& name[basis] != '('
&& name[basis] != ')'
&& name[basis] != ';'
&& name[basis] != ','
&& name[basis] != '.'
&& name[basis] != '"';
basis--) ;
You should be able to use a Set:
var excludes = new HashSet<Char> { ' ', '-', ... };
Then test if your character is in the set with
excludes.contains(someChar)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.