Which lines contain errors?
 
using System; 
namespace Inheritance 
{ 
      class A { } 
      interface Inner { } 
      struct S : A, Inner //1 
      { 
          int num = 10;   //2 
          public S()       //3 
          { 
          } 
          static S()      //4 
          { 
          } 
      } 
      class Program 
     { 
         static void Main(string[] args) 
         {
            S obj = new S(); //5 
         } 
     }
 }
 
Explanation
1 - structures do not support classical inheritance, and A is a class name
2 - fields of structures can not be initialized during the declaration
3 - it's not allowed to declare default constructors

Слідкуй за CodeGalaxy

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

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