text: Program to check if input is an integer or a string | C # program to check if a given string is a valid integer ; Returns true if s is a number else false ; Driver code ; Saving the input in a string ; Function returns 1 if all elements are in range '0 ▁ - ▁ 9' ; Function returns 0 if the input is not an integer
code: using System ; public class GFG { static bool isNumber ( string s ) { for ( int i = 0 ; i < s . Length ; i ++ ) if ( char . IsDigit ( s [ i ] ) == false ) return false ; return true ; } static public void Main ( String [ ] args ) { string str = "6790" ; if ( isNumber ( str ) ) Console . WriteLine ( " Integer " ) ; else Console . WriteLine ( " String " ) ; } }