How to check if string contain 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.IsDigit)) {
            Console.WriteLine("yes");
        } else {
            Console.WriteLine("no");
        }
    }
}



/*
run:

yes

*/

 



answered Nov 24, 2020 by avibootz

Related questions

...