Maha

Maha

  • NA
  • 0
  • 324.6k

NP52 Two objTwo = Two.New();

Oct 11 2007 4:35 AM

Hi Guys

 

NP52   Two objTwo = Two.New();

 

http://www.c-sharpcorner.com/UploadFile/rmcochran/instantiationFactory06232007153242PM/instantiationFactory.aspx

 

In the article (website address is given above) there is a following part: 

  

In this scenario, when we want to "new-up" our class, we call it through the static method as follows:

 

Number objTwo = Two.New();

 

The following code would not compile because the New() factory method now returns a "Number" object and not a "Two" object:

 

Two objTwo = Two.New();

 

There is an error. Two objTwo = Two.New(); must come instead of Number objTwo = Two.New();

 

And Number objTwo = Two.New(); must come instead of Two objTwo = Two.New();

 

I wish to confirm whether I correct or not. Please confirm it.

 

Thank you


Answers (2)