Pages

Wednesday, May 15, 2013

why constructor not support in virtual and override method?

Ans:

In case virtual method ,constructor not supported in c#, since constructor will not be having any bahaviour associated through constructor are treated as method
ex:
public class  A
  {
  public int i; // not support
  public virtual A(int i)
   {
     this.i=i;
    }
}
public class B:A
   {
     public int i; // not support
     public override B(int i)
      {
       this.i=i;
     }
}

No comments:

Post a Comment