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.

Follow CodeGalaxy

Mobile Beta

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