Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
raghulvarma
Starting Member
21 Posts |
Posted - 2008-10-10 : 11:56:28
|
plz explain me this class MyClass{public void display1(){Console.WriteLine("Hai");}}class MyClass1:MyClass{public void display2(){Console.WriteLine("Hai");}} Now in the main Class iestatic void Main(string[] args){MyClass1 c1 = new MyClass2();c1.display1();} I need to know what is the use of creaing an object for base class with the class that extends it.when I run this pgm I find only the method of MyClass1 !!!any help plz |
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-10-10 : 13:09:32
|
Yeah, cos you are using void, which sets it to return nothing. |
|
|
raghulvarma
Starting Member
21 Posts |
Posted - 2008-10-10 : 20:56:48
|
My question is at which situation do we use this concept that is MyClass1 c1 = new MyClass2(); If I am not wrong is it one way of achiving abstraction?if not plz tell me which concept of OOP that it use? |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-10-11 : 02:33:29
|
Well It seems to me that you are using winforms. I havent used winforms in c# , but use webforms. Which i believe are basically the same. But this is wrongMyClass1 c1 = new MyClass2();What i believe you are trying to do is MyClass1 c1 = new MyClass1();Which invaraibly is creating an instance of the class MyClass1 and assigning it to the object c1 |
|
|
|
|
|