So with GetType() we are able to find out the type of datatype like is it System.String, System.Int32 and so on. Please find below the code as well as their output. You can also just copy and paste code and check with different way in your Visual Studio IDE.
using System;
namespace CheckDataType
{
class Program
{
static void Main(string[] args)
{
char
charType = 'A';
string stringType = "Code By
Topic";
Int16 shortType = 1987;
Int32 intType = 2010;
Int64 longType = 2018;
Boolean boolType = true;
Console.WriteLine(charType.GetType());
Console.WriteLine(stringType.GetType());
Console.WriteLine(shortType.GetType());
Console.WriteLine(intType.GetType());
Console.WriteLine(longType.GetType());
Console.WriteLine(boolType.GetType());
Console.ReadLine();
}
}
}
0 comments:
Post a Comment