Specify which properties are defined incorrectly?
 
     public class Foo { 
          private int a; 
          private int c; 

          public int A {
            get { return a; } 
            set { a = value; } 
         }
 
         public int B {
            get { return 0; } 
         } 

        public int C { 
           set { c = value; } 
       } 

       protected int D { get; set; } 

       protected int E { get; private set; } 

       protected int F { public get; set; } 
 }
 
Explanation
A - property with explicit access methods.
B and C - properties with methods of read-only and write-only, respectively.
D - auto-implemented properties
E - the same, but with asymmetric access methods
F - property is defined incorrectly, since the visibility of the access method (public) can not be more than visibility properties (protected)
Details: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/x9fsa0sw(v=vs.90)

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C# quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes