Home  /  Questions  /  Question



50   50
Jun 09, 2015


Inheritance question


Hi All, 


I wondering if there is any sense with the following code 

public interface IMyInterface
    {

        void MyFunction();
    }

    public abstract class MyAbstructClass : IMyInterface
    {
        protected int myIntMember;
        protected string myStringMember;

        public abstract void MyFunction();

        protected void MyCommonFunction()
        {

        }
    }


    public class MyClass :  MyAbstructClass
    {
        public MyClass(int x, string y)
        {
            this.myIntMember = x;
            this.myStringMember = y;
        }

        public override void MyFunction()
        {
            
        }
    }


    

    class Program
    {
        static void Main(string[] args)
        {
            MyAbstructClass c = new MyClass(1, "hello");

            c.MyFunction();
        }
    }


Or that one 




 
public interface IMyInterface
    {

        void MyFunction();
    }

    public class MyBaseClass 
    {
        protected int myIntMember;
        protected string myStringMember;

        protected void MyCommonFunction()
        {

        }
    }


    public class MyClass :  MyBaseClass, IMyInterface
    {
        public MyClass(int x, string y)
        {
            this.myIntMember = x;
            this.myStringMember = y;
        }

        public void MyFunction()
        {
            
        }
    }


    

    class Program
    {
        static void Main(string[] args)
        {
            IMyInterface c = new MyClass(1, "hello");

            c.MyFunction();
        }
    }