<code lang="cs">
static void Main(string[] args)
{
List<string> s = new List<string>();
s.Add("asdasdasd");
}
string AllIsLetter(List<string> s)
{
foreach (string str in s)
{
foreach (char ch in str)
{
if (!Char.IsLetter(ch))
{
return "Не все строки содержат только буквы!";
}
}
}
return "В коллекции только буквы";
}
</code>
List<string> list = new List<string> { "sdfsd", "dfgdf", "ssss" };
bool result;
result = list.TrueForAll(s => s.All(c => Char.IsLetter(c)));
Console.WriteLine(result); //true
list = new List<string> { "sdf5", "dfgdf", "ssss" };
result = list.TrueForAll(s => s.All(c => Char.IsLetter(c)));
Console.WriteLine(result); //false
class Program
{
static void Main(string[] args)
{
var stringList = new List<string> {"asdasd","","adadasd","фывфывфыв","dвыацwe"};
Console.WriteLine(CheckList(stringList) ? bool.TrueString : bool.FalseString);
}
private static bool CheckList(IEnumerable<string> stringList)
{
return stringList.All(str => Regex.IsMatch(str, @"\A\p{L}*\Z"));
}
}