8
Answers

Object Data Type

Ask a question
Maha

Maha

11y
1.1k
1
In the following program if data type is object, GetType() method returning data type is assigned value data type.

If object obj4 = new object(); then only returning data type is System.Object.What is the reason for that?

using System;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int value = 5;
object obj1 = 12;
object obj2 = "Scarborough";
object obj3 = 'A';
object obj4 = new object();


Console.WriteLine(value.GetType());
Console.WriteLine(obj1.GetType());
Console.WriteLine(obj2.GetType());
Console.WriteLine(obj3.GetType());
Console.WriteLine(obj4.GetType());

Console.ReadKey();
}
}
}

/*
System.Int32
System.Int32
System.String
System.Char
System.Object
*/


Answers (8)