Reference variable of Interface

It is possible to create the reference variable of an Interface which is 100% abstract in nature.Then why it is not possible to create a reference of an Abstract class?

Questions by krish3636   answers by krish3636

Showing Answers 1 - 6 of 6 Answers

arupc

  • Feb 8th, 2015
 

This is the limitation of Abstract Keyword in C#.

  Was this answer useful?  Yes

ViBi

  • Apr 19th, 2015
 

It is possible

Code
  1. class Program

  2.     {

  3.         static void Main(string[] args)

  4.         {

  5.             MyBase b = new Derived();

  6.  

  7.             Hocky h = new Hocky();

  8.             h.Play(ref b);

  9.         }

  10.     }

  11.  

  12.    abstract class MyBase

  13.    {

  14.        public abstract void Add(int i, int j);

  15.    }

  16.  

  17.     class Derived : MyBase

  18.     {

  19.         public override void Add(int i, int j)

  20.         {

  21.                

  22.         }

  23.     }

  24.  

  25.     class Hocky

  26.     {

  27.         public void Play(ref MyBase b)

  28.         {

  29.             b.Add(10, 20);

  30.         }

  31.     }

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions