Answer to Question #328174 in C# for Bunny

Question #328174

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.

1
Expert's answer
2022-04-17T11:03:38-0400
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;




    }


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS