4
Answers

NP108 Declaring Objects

Ask a question
Maha

Maha

16y
2k
1

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)