Create a program using python programming language that determines the data type of a user input variables. Declare at least 3 user input variables then print out their data types.
internal class Program
{
static void Main()
{
Console.Write("First variable: ");
Parse(Console.ReadLine());
Console.Write("Second variable: ");
Parse(Console.ReadLine());
Console.Write("Third variable: ");
Parse(Console.ReadLine());
Console.ReadKey();
}
static void Parse(string variable)
{
if (int.TryParse(variable, out int intResult))
{
Console.WriteLine("Int");
return;
}
if (double.TryParse(variable, out double doubleResult))
{
Console.WriteLine("Double");
return;
}
Console.WriteLine("String");
return;
}
}
Comments
Leave a comment