Maha

Maha

  • NA
  • 0
  • 170.4k

NP108 Declaring Objects

Jul 26 2008 10:48 AM

Hi Guys

 

NP108 Declaring Objects

 

Usually when we declare an object, type and constructor method holds the same name. But in the following program it is not, please explain the reason.   

 

Object someObject = new StringReader("This is a StringReader");

 

Thank you

 

using System;

using System.IO;

 

class MainClass

{

    public static void Main()

    {

        Object someObject = new StringReader("This is a StringReader");

 

        if (someObject is TextReader)

        {

            Console.WriteLine(

                "is: someObject is a TextReader or a derived class");

        }

    }

}

/*

is: someObject is a TextReader or a derived class

*/


Answers (4)