Wats the diff between sealed class and private class in
inheritance

Answer Posted / vishal

Sealed Class:
When applied to a class, the sealed modifier prevents other
classes from inheriting from it. In the following example,
class B inherits from class A, but no class can inherit
from class B.

class A {}
sealed class B : A {}

You can also use the sealed modifier on a method or
property that overrides a virtual method or property in a
base class. This enables you to allow classes to derive
from your class and prevent them from overriding specific
virtual methods or properties.


Private Class :

Classes and structs that are not nested within other
classes or structs can be either public or internal. A type
declared as public is accessible by any other type. A type
declared as internal is only accessible by types within the
same assembly. Classes and structs are declared as internal
by default unless the keyword public is added to the class
definition. And yes, a class cannot be private unless of
course if it a nested class.

Is This Answer Correct ?    29 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between proc. Sent by val and by sub?

484


What does readonly mean in c#?

545


What is the difference between parse and tryparse in c#?

494


Write a sample code to write the contents to text file in c#?

483


What is private static in c#?

483






Are objects passed by reference in c#?

525


Why we use methods in c#?

561


How can you set image source dynamically from c# application to ”test.png” file?

642


What are anonymous functions in c#?

526


Name the method of servicebase class?

543


What is code verification?

537


What is type safe code?

476


Why do we use readonly in c#?

493


what is an exception in .net?

520


What is Co- and Contra-Variance in C#?

542