How can I find out what data type some variable is holding? (e.g. int, string, char, etc.)
I have something like this now:
using System;
using System
check out one of the simple way to do this
// Read string from console
string line = Console.ReadLine();
int valueInt;
float valueFloat;
if (int.TryParse(line, out valueInt)) // Try to parse the string as an integer
{
Console.Write("This input is of type Integer.");
}
else if (float.TryParse(line, out valueFloat))
{
Console.Write("This input is of type Float.");
}
else
{
Console.WriteLine("This input is of type string.");
}