using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var strs = new List { "PassWord", "PAssword", "PASSWord"}; var n = 2; foreach (var s in strs) { var res = s.Where(c => (c >= 65 && c <= 90)).Count(); Console.WriteLine("{0}: {1}", s, res == 2); } } }