title: C# Potential Interview Question…Too hard?
body: <p>Without running this code, identify which <code>Foo</code> method will be called:</p>
  
  <pre><code>class A
  {
     public void Foo( int n )
     {
        Console.WriteLine( "A::Foo" );
     }
  }
  
  class B : A
  {
     /* note that A::Foo and B::Foo are not related at all */
     public void Foo( double n )
     {
        Console.WriteLine( "B::Foo" );
     }
  }
  
  static void Main( string[] args )
  {
     B b = new B();
     /* which Foo is chosen? */
     b.Foo( 5 );
  }
  </code></pre>
  
  <p>Which method? And why? No cheating by running the code.</p>
  
  <p>I found this puzzle on the web; I like it and I think I'm going to use it as an interview question...Opinions?</p>
  
  <p>EDIT: I wouldn't judge a candidate on getting this wrong, I'd use it as a way to open a fuller discussion about the C# and CLR itself, so I can get a good understanding of the candidates abilities.</p>
  
  <p><strong>Source:</strong> <a href="http://netpl.blogspot.com/2008/06/c-puzzle-no8-beginner.html" rel="noreferrer">http://netpl.blogspot.com/2008/06/c-puzzle-no8-beginner.html</a></p>