<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PROGRAMMER DESK &#187; Inheritance</title>
	<atom:link href="http://vinayhatwal.wordpress.com/category/net/oops/inheritance/feed/" rel="self" type="application/rss+xml" />
	<link>http://vinayhatwal.wordpress.com</link>
	<description>Accept Changes To Develop Good Solutions</description>
	<lastBuildDate>Sun, 02 Aug 2009 10:34:20 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='vinayhatwal.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/fddfa1cd68a112c3fb6eca04033658e3?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>PROGRAMMER DESK &#187; Inheritance</title>
		<link>http://vinayhatwal.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vinayhatwal.wordpress.com/osd.xml" title="PROGRAMMER DESK" />
		<item>
		<title>Inheritance</title>
		<link>http://vinayhatwal.wordpress.com/2009/06/16/inheritance/</link>
		<comments>http://vinayhatwal.wordpress.com/2009/06/16/inheritance/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 08:48:51 +0000</pubDate>
		<dc:creator>vinayhatwal</dc:creator>
				<category><![CDATA[Inheritance]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[abstract]]></category>
		<category><![CDATA[Access Specifires]]></category>
		<category><![CDATA[MustInherit]]></category>
		<category><![CDATA[MustOverride]]></category>
		<category><![CDATA[New]]></category>
		<category><![CDATA[NonInheritable]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[Overridable]]></category>
		<category><![CDATA[override]]></category>
		<category><![CDATA[Overrides]]></category>
		<category><![CDATA[sealed]]></category>
		<category><![CDATA[Shadows]]></category>
		<category><![CDATA[virtual]]></category>

		<guid isPermaLink="false">http://vinayhatwal.wordpress.com/?p=143</guid>
		<description><![CDATA[Inheritance
Written by – Vinay Hatwal
Dt. 16-Jun-2009
                                                                               
Inheritance is the OOPs concept in which new classes form from the existing classes i.e. using the class functionality in the new classes. Inheritance was first introduced in 1967 for Simula, a language which was used for simulation so the name is Simula.
Inheritance is intended to help reuse existing code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=143&subd=vinayhatwal&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p align="center">Inheritance</p>
<p align="center">Written by – Vinay Hatwal</p>
<p align="center">Dt. 16-Jun-2009</p>
<p>                                                                               </p>
<p>Inheritance is the OOPs concept in which new classes form from the existing classes i.e. using the class functionality in the new classes. Inheritance was first introduced in 1967 for <a title="Simula" href="http://en.wikipedia.org/wiki/Simula">Simula</a>, a language which was used for simulation so the name is Simula.</p>
<p>Inheritance is intended to help <a title="Reusability" href="http://en.wikipedia.org/wiki/Reusability">reuse</a> existing code with little or no modification. Inheritance is also sometimes called generalization, because the <a title="Is-a" href="http://en.wikipedia.org/wiki/Is-a">is-a</a> relationships represent a hierarchy between classes of objects.</p>
<p>For Example, A “vehicle” is the generalization of “Car”, “Scooter”, “Bus” etc and the “Car”, “Scooter”, ”Bus” are the specialization of the “Vehicle”. Because the “Car” is a Vehicle so “Car” naturally inherits properties common to the entire vehicle like Color, No of Wheels, and EnginPower etc.</p>
<p>Following example show the inheritance in action. Shape is the Base Class and Square , Rectangle amd Circle are the classes derived from Shape Class and inherits all the functionality of the Shape class the shows the specialisation of the Shape Class.</p>
<div id="attachment_144" class="wp-caption aligncenter" style="width: 494px"><img class="size-full wp-image-144" title="in" src="http://vinayhatwal.files.wordpress.com/2009/06/in.jpg?w=484&#038;h=466" alt="Inheritance" width="484" height="466" /><p class="wp-caption-text">Inheritance</p></div>
<p><strong><span style="text-decoration:underline;">Inheritance in Action</span></strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><strong>VB.NET</strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Public Class BaseClass</p>
<p> </p>
<p>End Class</p>
<p> </p>
<p> </p>
<p>Public Class DerivedClass</p>
<p>    Inherits BaseClass</p>
<p> </p>
<p>End Class</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><strong>C#.NET</strong></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>public class BaseClass</p>
<p>{</p>
<p>}</p>
<p> </p>
<p>public class DerivedClass : BaseClass</p>
<p>{</p>
<p>}</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<p>Above DerivedClass Will contain all the inheritable funtionality of the BaseClass. Inheritane can be used in</p>
<p><strong> </strong></p>
<p><strong>VB.NET – Inherits</strong></p>
<p><strong>C#.NET &#8211; :</strong></p>
<p> </p>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;"> </span></p>
<p><span style="text-decoration:underline;">Access Specifires</span></p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="227" valign="top"><strong>Functionality</strong></td>
<td width="175" valign="top"><strong>VB.NET</strong></td>
<td width="157" valign="top"><strong>C#.NET</strong></td>
</tr>
<tr>
<td width="227" valign="top">Gives variable public access which means that there is no restriction on their accessibility</td>
<td width="175" valign="top">Public</td>
<td width="157" valign="top">public</td>
</tr>
<tr>
<td width="227" valign="top">Gives variable private access which means that they are accessible only within their declaration content</td>
<td width="175" valign="top">Private</td>
<td width="157" valign="top">private</td>
</tr>
<tr>
<td width="227" valign="top">Protected access gives a variable accessibility within their own class or a class derived from that class</td>
<td width="175" valign="top">Protected</td>
<td width="157" valign="top">protected</td>
</tr>
<tr>
<td width="227" valign="top">Gives variable friend access which means that they are accessible within the program that contains their declaration</td>
<td width="175" valign="top">Friend</td>
<td width="157" valign="top">internal</td>
</tr>
<tr>
<td width="227" valign="top">Gives a variable both protected and friend access</td>
<td width="175" valign="top">Protected Friend</td>
<td width="157" valign="top">protected internal</td>
</tr>
<tr>
<td width="227" valign="top">Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends</td>
<td width="175" valign="top">Static</td>
<td width="157" valign="top">static</td>
</tr>
<tr>
<td width="227" valign="top">Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure</td>
<td width="175" valign="top">Shared</td>
<td width="157" valign="top">static</td>
</tr>
<tr>
<td width="227" valign="top">Makes a variable only to be read and cannot be written</td>
<td width="175" valign="top">ReadOnly</td>
<td width="157" valign="top">-</td>
</tr>
</tbody>
</table>
<p> </p>
<p> </p>
<p><strong>Keywords used in Inheritance in VB.NET/C#</strong></p>
<p><strong> </strong></p>
<p><strong>1)      </strong><strong>MustInherit, MustOverride /abstract</strong></p>
<p><strong>2)      </strong><strong>Overridable/virtual</strong></p>
<p><strong>3)      </strong><strong>Overrides/override</strong></p>
<p><strong>4)      </strong><strong>NonInheritable/sealed</strong></p>
<p><strong>5)      </strong><strong>Shadows/New</strong></p>
<p> </p>
<p><strong><span style="text-decoration:underline;">Concepts Regarding Interitance</span></strong></p>
<p><strong>1)      </strong><strong>Abstraction</strong></p>
<p>Abstraction is &#8220;the process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use&#8221; (Richard Gabriel).</p>
<p>In Abstraction we will look only on the keywords</p>
<p><strong>a)      </strong><strong>MustInherit, MustOverride /abstract</strong></p>
<p> </p>
<p>Abstract Classes or MustInherit class can not me instantiated. The can only be inherited in the derived class.</p>
<p>For Example –</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>VB.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>Public MustInherit Class Base</p>
<p>    Public Sub NormalMethod()</p>
<p>    End Sub</p>
<p>    Public MustOverride Sub MustOverridableMethod()</p>
<p>End Class</p>
<p> </p>
<p> </p>
<p>Public Class Derived</p>
<p>    Inherits Base</p>
<p>    Public Overrides Sub MustOverridableMethod()</p>
<p> </p>
<p>    End Sub</p>
<p>End Class</p>
<p> </p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>C#.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>public abstract class Base</p>
<p>{</p>
<p>        public void NormalMethod()</p>
<p>        {</p>
<p>        }</p>
<p>        public abstract void MustOverridableMethod();</p>
<p>}</p>
<p>   </p>
<p>  public class Derived : Base</p>
<p>  {</p>
<p> </p>
<p>      public override void MustOverridableMethod()</p>
<p>              {</p>
<p>              throw new NotImplementedException();</p>
<p>      }</p>
<p>}</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p>In the above example if you are declaring the method as MustOverride/ abstract then u have to give definition of that method in the derived class. But if you are defining the method in the MustInherit/Abstract class then you may or may not define this method in the derived class.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>b)      </strong><strong>Overridable/virtual and Overrides/override</strong></p>
<p> </p>
<p>Overridable/virtual is used to polimorphically declare the base class method. A non overridable/not virtual method can not me polymorfically declared in the base class because it will hide the base class method in the derived class (Refer to Shadowing).</p>
<p>When we declare a Overridable/virtual method, it must contain a method body. Other wise the compiler will generate an error. Remember that, since Overridable/virtual methods are used for achieving polymorphism and since polymorphism works only with objects, it not possible to declare a static method as virtual in C#. Similarly the private methods are also not possible to declare virtual, since they can&#8217;t override inside a derived class.</p>
<p> </p>
<p>For Example –<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>VB.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>Public Class PolyBase</p>
<p>    Public Overridable Function GetName() As String</p>
<p>        Return &#8220;Base Polymorphic Class&#8221;</p>
<p>    End Function</p>
<p>End Class</p>
<p> </p>
<p>Public Class PolyDerived</p>
<p>    Inherits PolyBase</p>
<p>    Public Overrides Function GetName() As String</p>
<p>        Return &#8220;Derived Polymorphic Class&#8221;</p>
<p>    End Function</p>
<p>End Class</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>C#.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>public class PolyBase</p>
<p>    {</p>
<p>        public virtual string GetName()</p>
<p>        {</p>
<p>            return &#8220;Base Polymorphic Class&#8221;;</p>
<p>        }</p>
<p>    }</p>
<p> </p>
<p>    public class PolyDerived : PolyBase</p>
<p>    {</p>
<p>        public override string GetName()</p>
<p>        {</p>
<p>            return &#8220;Derived Polymorphic Class&#8221;;</p>
<p>        }</p>
<p>    }</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p><strong>2)      </strong><strong>Sealed Classes &#8211; </strong></p>
<p> </p>
<p>Sealed Class can be instanciated but can not be inherited in another class .In VB.Net NotInheritable keyword is used to declare a class Seald and In C#.Net it is declared by sealed.</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>VB.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>Public NotInheritable Class NotInheritableClass</p>
<p>    Public Function Fun1() As String</p>
<p>        Return &#8220;My class can not be inherited&#8221;</p>
<p>    End Function</p>
<p>End Class</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>C#.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>sealed class NonInheritableClass</p>
<p>       {</p>
<p>        public string Fun1()</p>
<p>        {</p>
<p>            return &#8220;this class can not be inherited&#8221;;</p>
<p>        }</p>
<p>}</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>3)      </strong><strong>Shadowing</strong></p>
<p>In .Net it is possible to declare the member of the base class with the same name in the derived class. In this class we are actully hiding the base class member in the derived class , if u do so then .Net compiler will show a warning.</p>
<p>Consider the following example-</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>VB.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><img class="aligncenter size-full wp-image-145" title="sh" src="http://vinayhatwal.files.wordpress.com/2009/06/sh.jpg?w=719&#038;h=222" alt="sh" width="719" height="222" /></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>C#.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><img class="aligncenter size-full wp-image-146" title="ssss" src="http://vinayhatwal.files.wordpress.com/2009/06/ssss.jpg?w=625&#038;h=269" alt="ssss" width="625" height="269" /></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p> </p>
<p>See the compiler warning closely.</p>
<p>In VB.Net it is clearly advising to use the Shadows with the new Fun1() to hide the base class functionality. Here the correct code is -</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>VB.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>Public Class Base</p>
<p>    Private x As Integer</p>
<p>    Private y As Integer</p>
<p>    Public Function Fun1() As Integer</p>
<p>        Return x + y</p>
<p>    End Function</p>
<p>End Class</p>
<p> </p>
<p> </p>
<p>Public Class Derived</p>
<p>    Inherits Base</p>
<p>    Public Shadows Function Fun1() As Integer</p>
<p>        Return 10</p>
<p>    End Function</p>
<p>End Class</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>Shadows keyword hides the base class functionality and warning too.</p>
<p> </p>
<p>And in the C# it is advising to use the new keyword to hide the base class method. Here the correct code is-</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>C#.NET</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>class Base</p>
<p>    {</p>
<p>        private  int x = 10;</p>
<p>        private int y = 20;</p>
<p>        public int Fun1()</p>
<p>        {</p>
<p>            return x + y;</p>
<p>        }</p>
<p>    }</p>
<p>   </p>
<p>    class Derived : Base</p>
<p>    {</p>
<p>        public new int Fun1()</p>
<p>        {</p>
<p>            return 10;</p>
<p>        }</p>
<p>    }</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p> </p>
<p>__________________________________________________________________________</p>
<p><strong> </strong></p>
Posted in Inheritance Tagged: .Net, abstract, Access Specifires, Inheritance, MustInherit, MustOverride, New, NonInheritable, OPPS, Overridable, override, Overrides, sealed, Shadows, virtual <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vinayhatwal.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vinayhatwal.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vinayhatwal.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vinayhatwal.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vinayhatwal.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vinayhatwal.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vinayhatwal.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vinayhatwal.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vinayhatwal.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vinayhatwal.wordpress.com/143/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vinayhatwal.wordpress.com&blog=4320862&post=143&subd=vinayhatwal&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://vinayhatwal.wordpress.com/2009/06/16/inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/30134ff30180ffc15825d15c005dbce5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vinayhatwal</media:title>
		</media:content>

		<media:content url="http://vinayhatwal.files.wordpress.com/2009/06/in.jpg" medium="image">
			<media:title type="html">in</media:title>
		</media:content>

		<media:content url="http://vinayhatwal.files.wordpress.com/2009/06/sh.jpg" medium="image">
			<media:title type="html">sh</media:title>
		</media:content>

		<media:content url="http://vinayhatwal.files.wordpress.com/2009/06/ssss.jpg" medium="image">
			<media:title type="html">ssss</media:title>
		</media:content>
	</item>
	</channel>
</rss>