Can we have a method of sealed type?

Posted by Rajendra.prasad under C# on 4/18/2010 | Views : 2146 | Status : [Member] | Replies : 2
Hi All,
Can we have a method of sealed type?

Regards,
Rajendra




Responses

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable
Posted by: Pavanandey on: 4/20/2010 [Member] Bronze

Up
0
Down


public class BaseClass
{
public sealed int Add(int a, int b)
{
a = a + b;
return a;
}
public int Minus(int a, int b)
{
a = a - b;
return a;
}
}

public class ChildClass : BaseClass
{
public override int Minus(int a, int b)
{
a = a - b;
return a;
}
public override int Add(int a, int b)
{
a = a + b;
return a;
}
}


Consider the above code gives u an error , since u cannot have a sealed method type for add in baseclass since it is being overridden in the base class..

the sealed methods cannot be overridden

Thanks
Pavan Kumar
Mark Answer if this fits the need

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

Login to post response