GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 356 of 436    Print  
Is there any way by which a class is made sealed as in C# that other class cannot inherit from it. Please include code.

  
Total Answers and Comments: 7 Last Update: October 25, 2006     Asked by: khurram 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 24, 2006 02:31:51   #1  
Joe        

RE: Is there any way by which a class is made sealed a...

A class can be made sealed in c# using the sealed keyword. When you do that it implies that the class cannot be inhereted. You can extend this functionality to the individual methods as well. In case you want a class to be inhereted excluding one of its methods just make that particular method sealed.


 
Is this answer useful? Yes | No
August 25, 2006 05:21:23   #2  
rashmi        

RE: Is there any way by which a class is made sealed a...

By using keyword sealed .

EX:

sealed class SealedClass
{
}


 
Is this answer useful? Yes | No
August 25, 2006 05:34:23   #3  
Prasad        

RE: Is there any way by which a class is made sealed a...
Use the keyword Shared for VB.Net to get the same effect as sealed in C#
 
Is this answer useful? Yes | No
September 05, 2006 13:59:15   #4  
ankit srivastava        

RE: Is there any way by which a class is made sealed a...

sealed methods are those methods which cant be overriden in the derived class. making the method sealed does not means that it will be excluded


 
Is this answer useful? Yes | No
October 20, 2006 13:12:10   #5  
jose        

RE: Is there any way by which a class is made sealed a...
If you use struct in C# that's also implicitly sealed . But your question is specific to class not struct. FYI.
 
Is this answer useful? Yes | No
October 25, 2006 02:41:20   #6  
Iqbal Basha        

RE: Is there any way by which a class is made sealed a...

Hey

sealed (C#.net) equivalent in vb.net is not Shared but its NotInheritable keyword.

Shared (vb.net) is equivalent to static(C#.net).

please reply to answer only if you're very much sure.

- basha G.


 
Is this answer useful? Yes | No
October 25, 2006 13:15:06   #7  
Rahul        

RE: Is there any way by which a class is made sealed a...
Sealed in C#.NET is NotInheritable in VB.NET NOT shared
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape