跳至主要内容

👩‍💻 判斷字串是否為數字

StringName.All(char.IsDigit);
using System;
using System.Linq;

public class IdentifyString
{
public static void Main()
{
string number = "123456";
if(number.All(char.IsDigit))
{
Console.WriteLine("The Given String is a Number.");
}
else
{
Console.WriteLine("The Given String is Not a Number.");
}
}
}

ref: C# 識別字串是否為數字 | D棧 - Delft Stack