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
What is the difference between mobile application and desktop application?
What are the properties in c#?
Can you put two constructor with the same structure in a class?
Why should I use interface in c#?
What is difference between il and dll ?
What does mean c#?
How long has c# been around?
When a Static Constructor is called in a Class?
what happens if you inherit multiple interfaces and they have conflicting method names?
What is the Signification of the "new " keyword in C#? example
What do multicast delegates mean?
What are the Uses of CLR
What is disco?
How can I produce an assembly?
What is a generic class?