using System.Text.RegularExpressions;
public static void Main()
Console.WriteLine(ValidatePassword("iLoveYou"));
Console.WriteLine(ValidatePassword("P1zz@"));
Console.WriteLine(ValidatePassword("Fhg93@"));
Console.WriteLine(ValidatePassword("RMmmX2"));
public static bool ValidatePassword(string password)
if (password.Length >= 6 && password.Length <= 24)
Regex regex = new Regex(@"^(.{0,7}|[^0-9]*|[^A-Z])$");
Match match = regex.Match(password);