Blog Stats
  • Posts - 21
  • Articles - 0
  • Comments - 12
  • Trackbacks - 17

 

Feel Smart?

I saw an interesting snippet of code last night on Greg's blog. What do you think the output is? Find out if you are right here.

using System;

 

class Base {

    public virtual void Foo(string x) {

        Console.WriteLine("Base.Foo(string");

    }

}

 

class Derived : Base {

    public override void Foo(string x) {

        Console.WriteLine("Derived.Foo(string)");

    }

 

    public virtual void Foo(object o) {

        Console.WriteLine("Derived.Foo(object)");

    }

}

 

class Test {

    static void Main() {

        new Derived().Foo("this is a string");

    }

}


Feedback

No comments posted yet.


Post a comment





 

Please add 6 and 4 and type the answer here:

 

 

Copyright © Aaron Feng