- I want to get input from user and print the type of the input given by user.
- I have tried this.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{
static void Main(String[] args)
{
var userObj = Console.ReadLine();
// if input is 5 it should print it is of type int.
//if input is 5.4 it should print it is of type double.
Console.WriteLine(userObj.GetType());// printing only string
}
}
also tried this but always going false
using System;
class Solution
{
static void Main(String[] args)
{
var userObj = Console.ReadLine();
if (string.Format(userObj) == string .Format("0"))
{
Console.WriteLine("it is of type interger");
}
}
}