Explain about this kind of things(protected & private & abstract & public and etc) and give example about how to use this and when it is possible to use them?
Joe Wilson
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
A new access modifier will almost certainly be introduced in C# 6.0 which will be defined as follows:
private protected
The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class provided it is declared in the same assembly.
In effect:
'protected internal' means protected OR internal
'private protected' means protected AND internal
However, the name 'private protected' is only provisional and will probably be changed to something which more clearly expresses the underlying concept.
All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:
The type or member can be accessed by any code in the same assembly, but not from another assembly.
protected internal
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.
The abstractkeyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.
An abstract class cannot be instantiated. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. For example, a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class.
VulpesPosted Apr 27, 2014, 3:10 PM
Abhay ShankerPosted Apr 27, 2014, 1:57 PM
All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:
The type or member can be accessed by any other code in the same assembly or another assembly that references it.
The type or member can be accessed only by code in the same class or struct.
The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.
The type or member can be accessed by any code in the same assembly, but not from another assembly.
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.
An abstract class cannot be instantiated. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. For example, a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class.
Sanjay SinghPosted Apr 27, 2014, 7:29 AM
http://www.tutorialspoint.com/java/java_access_modifiers.htm