Tuesday, July 13, 2004

Funda No.1 : Sealed Modifier in C# - Really Good

Hi Guys,

Look into it.....

Funda No.1 :

In Beta 1, the Sealed modifier, when used on method overrides, yielded a compiler error: "The modifier 'sealed' is not valid for this item." In Beta 2, the compiler recognizes the Sealed modifier.

Sample Code Snippet:
public class B : A
{
public B()
{
}
sealed public override string Method1()
{
return "Override";
}
}

Use of the Sealed modifier, in conjunction with the override method, will prevent anything classes derive from class B from further overriding Method1(), which originally was provided by the base class A.

So Hows That....

No comments: