Tuesday, 24 January 2017

STATIC AND INSTANCE CLASS MEMBERS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{

    class Circle
    {
       static float _PI;
        int _Radius;

        static Circle()
        {
            Circle._PI = 3.141F;
        }

        public Circle(int Radius)
        {
            this._Radius = Radius;
        }

        public float CalculateArea()
        {
            return Circle._PI * this._Radius * this._Radius;
        }


    }
    class Program
    {
        static void Main(string[] args)
        {
            Circle C1 = new Circle(5);
            float Area1 = C1.CalculateArea();
            Console.WriteLine("Area = {0}", Area1);
            Console.ReadLine();


            Circle C2 = new Circle(6);
            float Area2 = C2.CalculateArea();
            Console.WriteLine("Area = {0}", Area2);
            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment