How to check if string contain uppercase and lowercase characters and digits with Linq in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    static void Main() {
        String s = "C# 9.0 VB.NET Python";
        
        if (s.Any(char.IsUpper) && s.Any(char.IsLower) && s.Any(char.IsDigit)) {
            Console.WriteLine("yes");
        } else {
            Console.WriteLine("no");
        }
    }
}



/*
run:

yes

*/

 



answered Nov 24, 2020 by avibootz
...