People discussed many attempts to use regular expressions, but this is wrong. In such simple criteria as yours, this is simple.
Apparently, first thing is to check up string length. And then you have to have some local variable,
byte score = 0;
and accumulate the password score by its characters. Make a loop by all password characters and add to score if you encounter a digit, a letter, a punctuation character, and so on. Don't count score twice, have some Boolean flags (in simplest variant of this solution), such as
hasLetter
,
hasDigit
and do the check only if it does not have it yet.
Use the methods like
System.Char.IsLetter
,
System.Char.IsNumber
,
System.Char.IsPunctuation
or
System.Char.IsLetterOrDigit
, etc.
Please see:
https://msdn.microsoft.com/en-us/library/system.char%28v=vs.110%29.aspx.
At the end, compare accumulated score with the required.
—SA