-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Prasanna_kakanoor
Message 3 in Discussion


The sealed modifier is used to prevent derivation from a class. An error occurs if a 
sealed class is specified as the base class of another class. A sealed class cannot 
also be an abstract class. 

The sealed modifier is primarily used to prevent unintended derivation, but it also 
enables certain run-time optimizations. In particular, because a sealed class is known 
to never have any derived classes, it is possible to transform virtual function member 
invocations on sealed class instances into non-virtual invocations. 

In C# structs are implicitly sealed; therefore, they cannot be inherited. 

using System;
sealed class MyClass 
{
   public int x; 
   public int y;
}

class MainClass 
{
   public static void Main() 
   {
      MyClass mC = new MyClass(); 
      mC.x = 110;
      mC.y = 150;
      Console.WriteLine("x = {0}, y = {1}", mC.x, mC.y); 
   }
}

In the preceding example, if you attempt to inherit from the sealed class by using a 
statement like this: 

class MyDerivedC: MyClass {} // Error 

You will get the error message:
'MyDerivedC' cannot inherit from sealed class 'MyBaseC'. 


Regards,
Prasanna K L [MCAD(CM) | MCSD.NET(Early Achiever)] [MS Community Star]

|Sr. Software Engineer�|First American Interactive Division|Office:+91 80�5115 6050  
Extn 4084 |Mobile:+91 98452 76356�|Fax:+91 80�841 1858 |[EMAIL PROTECTED] |
|Unit 1, Level 1, Explorer Building, International TechPark, Whitefield Road, 
Bangalore-560066|India| Website: www.firstam.com |

-----Original Message-----
From: BDOTNET [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 16, 2003 10:05 AM
To: BDOTNET
Subject: Sealed Class



New Message on BDOTNET


Sealed Class
Reply

�
Recommend 
Message 1 in Discussion 

From: Ambrose 

Hi All,
* �What is a Sealed Class?
* �Difference between const and static readonly�(Readonly and Const)
* �When GC will be called in a Application How can we called programatically
* When the Destructor will be called?
Thanks
Anandraj.A.


View other groups in this category. 


Also on MSN:
Start Chatting�|�Listen to Music�|�House & Home�|�Try Online Dating�|�Daily Horoscopes 

Passport Member Services. 
For other questions or feedback, go to our Contact Us page. 

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list. 
Remove my e-mail address from BDOTNET. 



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to