Tuesday, May 5, 2015

Do you Override methods in order to save memory / waste less memory?

If not, what's his purpose?

example:

abstract class Shape
{
    public abstract int Area();

}

    class Square : Shape
    {
        public int Lato;
        public Square(int iLato)
        {
            this.Lato = iLato;
        }
        public override int Area()
    {
        return this.Lato * this.Lato;
    }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Shape A = new Square(10);
            Console.WriteLine("There you go: {0}", A.Area());
            Console.ReadLine();
        }
    }
}


No comments:

Post a Comment