Tag: Method cannot be inherited by abstract span program Str modifier instance RAC
First: The definition of a basic class
1 class Person 2 {3 // I am a person class, the default class modifier is intenal and can only be accessed in the current assembly 4 }
The same class as the example above is defined as follows, meaning the same
1 Internal class Person1 2 {3 // I am a Person1 class that allows access to the current assembly, other items cannot access 4 }
Second: Declare classes that can be accessed in the current assembly or accessed in other projects, as defined below
1 Public class Person2 2 {3 // I am a Person2 class that can be accessed in the current assembly or accessed in other projects 4 }
Third: the definition of abstract class
1 Abstract class Person3 2 {3 // I am an abstract class that can only be accessed in the current assembly by default, abstract classes cannot be instantiated and can only be inherited 4 }
Definition of abstract class The second way is to add the keyword internal
1 Internal Abstract class Person3 2 {3 // I am an abstract class that can only be accessed in the current assembly, the abstract class cannot be instantiated and can only be inherited 4 }
The third method of the abstract class definition is the keyword public, which cannot be sealed with the keyword because abstract classes can only be inherited and sealed classes can only be instantiated and cannot be inherited
1 Public Abstract class Person4 2 {3 // I am an abstract class that can be accessed in the current assembly or in other projects, the abstract class cannot be instantiated and can only be inherited 4 }
Declaration of the Seal class IV
1 Public Sealed classPerson52 {3 //sealed classes can only be instantiated and cannot be inherited, accessible in any project4 }5 Internal Sealed classPerson66 {7 //sealed classes can only be instantiated, cannot be inherited, are accessible in the current assembly, and cannot be accessed by other projects8 }9 Sealed classPerson7Ten { One //sealed classes can only be instantiated, cannot be inherited, are accessible in the current assembly, and cannot be accessed by other projects A}
How to define classes in C # Object-oriented programming to understand the role of each keyword