Which lines contain compilation errors?
 
    public class Foo 
    { 
           private double field;

           public double A 
           { 
                get { return field + 10.0; }        // 1 
                set { field = value - 10.0; }       // 2 
            } 
            public int B { get; private set; }    // 3 
       }

      public static class Program 
     { 
        public static void Main() 
       { 
           Foo f = new Foo(); 

          double a = f.A;      // 4 
          int b = f.B;          // 5 
          f.B = 10;            // 6 
       } 
   }
 
Explanation
A - property with access methods for reading and writing.
B - auto-implemented property with asymmetric access methods. Property is available ror reading only to members of the class
Details here:
https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/x9fsa0sw(v=vs.90)

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести