Back to list
Views:   3.5K
Replies:  0
Archived

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();
        }
    }

 
Amit Malina, Jun 09, 2015


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0