using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class PasswordValidator { private int _MinLength = 5; public int MinLength { get { return _MinLength; } set { _MinLength = value; } } private int _MinNonAlphaNumeric = 0; public int MinNonAlphaNumeric { get { return _MinNonAlphaNumeric; } set { _MinNonAlphaNumeric = value; } } public bool Validate(string password) { if ( password.Length <= _MinLength ) { return false; } if ( CountNonAlpha(password) <= _MinNonAlphaNumeric ) { return false; } return true; } private int CountNonAlpha(string text) { int nonAlphaCount = 0; foreach ( char c in text ) { if ( !Char.IsLetterOrDigit(c) ) { nonAlphaCount++; } } return nonAlphaCount; } } }