Thursday, July 5, 2007

Inheritance Question

public interface I1
{
 void Method1();
}
 
public class A : I1
{
 public void MethodA()
 {
  Console.WriteLine("In Method A");
 } 
 
 public void Method1()
 {
  Console.WriteLine("I am in interface Method1");
 }
}
 
[STAThread]
static void Main()
{
 I1 obj = new A();
 //Now can I access I1.MethodA();
}
 
Question: Can I access MethodA from obj.
 
Answer: Nop. You can't access it.

No comments: