public abstract class A
 {
        public virtual string Print() { return "A"; }
 }

 public class B : A 
{
    public override new string Print() { return "B"; }
 }

 public class C : B
 { 
   public string Print() { return "C"; }
 
}
 
What will be the result of the following code execution?:
 A ac = new C();
 Console.WriteLine(ac.Print());
 
Explanation
Overriding a method and using a new modifier in one statement is not allowed since two modifiers have mutually exclusive meanings.

@laor31692 fixed ;)

2017 Dec 15, 1:49:30 PM

public virtual string Print() { return "A" } After return statement there should be semicolon, or will be compilation error :)

2017 Dec 15, 9:46:52 AM

Follow CodeGalaxy

Mobile Beta

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