+ 2
How to identify type of input read from the keyboard in C# ?
if the input is given as '2' or such then it should print it as integer and if string then to print as string
3 Antworten
+ 3
You can convert the input to an integer
int.parse(Console.Read()) .. output is read as a string
+ 3
use int.TryParse(), it will try to parse it as an integer but if it fails you can just assign it as a string and you wont have to do any exception handling
0
I think you can use regular expression to define several templates to match many data types such as integer, real number, complex number, telephone number :-D, string, or more specifically string like email address, proper names, etc.