using System;
namespace ConsoleApplication_C_Sharp
{
class Program
{
static void Main(string[] args)
{
object[] o_types = { 87, (long)9835, (byte)3, (sbyte)-8, 3.14, (float)5.87, "string" };
foreach (var value in o_types)
{
Type t = value.GetType();
if (t.Equals(typeof(byte)))
Console.WriteLine("{0, 4}: is 8-bit unsigned byte.", value);
else if (t.Equals(typeof(sbyte)))
Console.WriteLine("{0, 4}: is 8-bit signed byte.", value);
else if (t.Equals(typeof(int)))
Console.WriteLine("{0, 4}: is a 32-bit integer (int).", value);
else if (t.Equals(typeof(long)))
Console.WriteLine("{0, 4}: is a 64-bit integer (long).", value);
else if (t.Equals(typeof(float)))
Console.WriteLine("{0, 4}: is a single-precision floating-point (float).", value);
else if (t.Equals(typeof(double)))
Console.WriteLine("{0, 4}: is a double-precision floating-point (double).", value);
else if (t.Equals(typeof(string)))
Console.WriteLine("'{0, 4}': is Unicode characters (string).", value);
}
}
}
}
/*
run:
87: is a 32-bit integer (int).
9835: is a 64-bit integer (long).
3: is 8-bit unsigned byte.
-8: is 8-bit signed byte.
3.14: is a double-precision floating-point (double).
5.87: is a single-precision floating-point (float).
'string': is Unicode characters (string).
*/