Sunday, February 10, 2019

New Access Specifier in C sharp 7.2

In C# 7.2 a private protected has been added. So they are total 6 access specifier
 
From C Sharp 7.2.
  •         public
  •         protected
  •         internal
  •         private
  •         protected internal
  •         private protected
  To know about previous access specifier please go through this.


Private Protected: It really means protected AND internal.

 
From the above Example you can see that it gives Me Error. Reason is
 
 

To Fix this,
In Visual Studio 2017 first, we need to change the Language Type to C Sharp 7.2 as shown below

Goto Project File-> Right Click and Select Properties.

That is - member is accessible only to child classes which are in the same assembly, but not to child classes which are outside assembly.

 
Now let me try to access this From the Outside Assembly.
1) private protected member is inaccessible outside the assembly for the child class.


 
2) private protected member is inaccessible inside the assembly for non-inherited class.
 

Error:


No comments:

Post a Comment

Thank you for visiting my blog

Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...