What will be the result of code execution?
 
    struct A {
       public virtual void foo() {  
          Console.WriteLine("A"); 
       } 
    } 
 
  struct B : A { 
     public virtual override void foo() { 
          Console.WriteLine("B"); 
     }
  } 

 class Program 
 {
    static void Main(string[] args) { 
       A v = new B();
       v.foo(); 
     }  
  }
 
Explanation
The program will not compile because of two reasons:
1. Structures can not have virtual methods;
2. Structures can be extended only from the interfaces.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты