interview purpose i want answers

Posted by Ramana under Interview Questions on 3/22/2012 | Points: 10 | Views : 872 | Status : [Member] | Replies : 4
what is overriding?give me one example?




Responses

Posted by: Sksamantaray on: 3/22/2012 [Member] Silver | Points: 25

Up
0
Down
Hi ,
Refer to this:
http://www.codeproject.com/Articles/18734/Method-Overriding-in-C

Thanks,
Sanjay

Ramana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 3/22/2012 [Member] Starter | Points: 25

Up
0
Down
Hi ,
check this link
http://msdn.microsoft.com/en-us/library/ebca9ah3%28v=vs.71%29.aspx

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Ramana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shravankomirineni on: 3/22/2012 [Member] Starter | Points: 25

Up
0
Down
Use the override modifier to modify a method, a property, an indexer, or an event.
u cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.
// cs_override_keyword.cs
// Calling overriden methods from the base class
using System;
class TestClass
{
public class Square
{
public double x;

// Constructor:
public Square(double x)
{
this.x = x;
}

public virtual double Area()
{
return x*x;
}
}

class Cube: Square
{
// Constructor:
public Cube(double x): base(x)
{
}

// Calling the Area base method:
public override double Area()
{
return (6*(base.Area()));
}
}

public static void Main()
{
double x = 5.2;
Square s = new Square(x);
Square c = new Cube(x);
Console.WriteLine("Area of Square = {0:F2}", s.Area());
Console.WriteLine("Area of Cube = {0:F2}", c.Area());
}
}

Output

Area of Square = 27.04
Area of Cube = 162.24



Ramana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 3/22/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

visit this link

http://stackoverflow.com/questions/1529792/how-to-develop-a-proxy-server-using-dotnet


R D Patel

Ramana, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response