-2

How to check the given input is string or integer?

Ex

if i'm giving my input as "vinoth".

i want my output like this

"It is a string".

if i'm giving my input as 123.

i want my output like this

"It is a integer".

Vinoth
  • 74
  • 1
  • 11

1 Answers1

0
string st = "your string";
int number = 0;
bool result = int.TryParse(st , out number );

if result is true then it is number else string.

You can do same for different numeric types also.

Imad
  • 7,126
  • 12
  • 55
  • 112