PDA

View Full Version : Virtual methods


us9898
01-09-2010, 06:39 PM
Hi,

I would like to know what is the significance of declaring the methods of a sealed class as virtual?

Like
sealed class MySealedClass
{
public int x;
public virtual int add()
{
return x+x;
}

}

something that like the complier generates when we delare a delegate.

oracleguy
01-10-2010, 08:58 PM
There isn't any point to making it virtual as far as I know. I am almost surprised the compiler doesn't complain about it since it does if you declare a method as abstract and virtual. So I would have thought it would have a similar check for a useless adjective on the method with sealed classes.