c# - Counting number of occurrences of characters from array in string? -


i'm writing code determine whether password contains enough punctuation characters.

how count number of occurrences of characters set?

something along these lines:

private const string nonalphanumericcharset = "#*!?£$+-^<>[]~()&"; ... public static bool passwordmeetsstrengthrequirements(string password) {     return password.length >= minimum_password_length && password.numberofoccurences(nonalphanumericcharset.tochararray()) >= minimum_nonalphanumeric_chars; } 

bonus points elegant linq solution.

how count number of occurences of characters set?

var count = password.count(nonalphanumericcharset.contains); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -