Is there any way by which a class is made sealed as in C# that other class cannot inherit from it. Please include code.

Showing Answers 1 - 7 of 7 Answers

Joe

  • Aug 24th, 2006
 

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.

  Was this answer useful?  Yes

rashmi

  • Aug 25th, 2006
 

By using keyword sealed .

EX:

sealed class SealedClass
{
 }

  Was this answer useful?  Yes

Prasad

  • Aug 25th, 2006
 

Use the keyword "Shared" for VB.Net to get the same effect as "sealed" in C#

  Was this answer useful?  Yes

ankit srivastava

  • Sep 5th, 2006
 

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

  Was this answer useful?  Yes

jose

  • Oct 20th, 2006
 

If you use struct in C# that's also "implicitly sealed". But your question is specific to "class" not struct. FYI.

  Was this answer useful?  Yes

Iqbal Basha

  • Oct 25th, 2006
 

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.

  Was this answer useful?  Yes

Rahul

  • Oct 25th, 2006
 

Sealed in C#.NET is NotInheritable in VB.NET NOT "shared"

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions