In the article, I would brief about C#.net OOPs concepts. Lets create a new console application. Open VS 2012 >New Projects > Visual C# > Windows> Console Application. And then add a class called BlogPage, this class has public property functions , private variable and public method and 1 public virtual method as shown.
In our main method create an object of BlogPage and set members as below and run the application.
In our main method create an object of BlogPage and set members as below and run the application.
Let about one more class file and define two WordPressBlog and GoogleBlog. These classes inherit BlogPage and overrides the virtual BlogLayout method according to its own implementation. Let create object of WordPressBlog and GoogleBlog classes and run the application. In output console, BlogLayout outputs are shown are from the derviced class implementation.
Lets see a kind of real time, implementation using this example. Instead of base class feature, we would define BlogPage as an abstract class which can only be inherited and abstract method should be implemented in derived class.
In the main method, based on users input, we would create an object of derived class as shown below.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.