This question already has an answer here:
- How do I identify if a string is a number? 18 answers
Is there a way to write code so that when a user gives input, either a string or a number, that the program will choose the most appropriate of the available variables that have been declared?
Pseudocode example:
static void Main()
{
int A;
string B;
Console.Write("enter something: ");
if (user enters a number)
A = int.Parse(Console.ReadLine());
else
B = Console.ReadLine();
}
Aucun commentaire:
Enregistrer un commentaire