Answers for "c# check string is number regex"

C#
8

c# how to check string is number

string s1 = "123";
string s2 = "abc";

bool isNumber = int.TryParse(s1, out int n); // returns true
isNumber = int.TryParse(s2, out int n); // returns false
Posted by: Guest on August-23-2020
1

c# regex number only

Regex

string input = "1-205-330-2342";
string result = Regex.Replace(input, @"[^d]", "");  //number only
Posted by: Guest on March-16-2021

C# Answers by Framework

Browse Popular Code Answers by Language