N
Nilesh
I am confused about the purpose of 'new' in overriding.
Consider following example.
<code_snippet>
using console = System.Console;
public class TestClass
{
public static void Main()
{
Base oBase = new Base();
oBase.test_call();
Derived oDerived = new Derived();
oDerived.test_call();
Base oDerived2 = new Derived();
oDerived2.test_call();
console.ReadLine();
}
}
class Base
{
public void test_call()
{
console.WriteLine("Base::test_call()");
}
}
class Derived : Base
{
public void test_call()
{
console.WriteLine("Derived::test_call()");
}
}
</code_snippet>
In the derived classes' test call method, what is the use of adding
new? i.e.
new public void test_call()
Both the cases produce same result. So what is the purpose of 'new'?
Am i missing something too obvious?
Thanks in advance
Nilesh Dhakras
Consider following example.
<code_snippet>
using console = System.Console;
public class TestClass
{
public static void Main()
{
Base oBase = new Base();
oBase.test_call();
Derived oDerived = new Derived();
oDerived.test_call();
Base oDerived2 = new Derived();
oDerived2.test_call();
console.ReadLine();
}
}
class Base
{
public void test_call()
{
console.WriteLine("Base::test_call()");
}
}
class Derived : Base
{
public void test_call()
{
console.WriteLine("Derived::test_call()");
}
}
</code_snippet>
In the derived classes' test call method, what is the use of adding
new? i.e.
new public void test_call()
Both the cases produce same result. So what is the purpose of 'new'?
Am i missing something too obvious?
Thanks in advance
Nilesh Dhakras