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

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

formula - R: how to pass in a reference to the variable in glm or lm? -