|
Post by Admin on Jun 6, 2014 20:15:10 GMT -5
using System; class Circle { float _PI = 3.14F; int _Radius;
public Circle(int Radius) { this._Radius = Radius; }
public float CalculateArea() { return this._PI * this._Radius * this._Radius; } }
class Program { public static void Main() { Circle C1 = new Circle(5); float Area = C1.CalculateArea();
Console.WriteLine("Area = {0}", Area);
Circle C2 = new Circle(6); float Area = C2.CalculateArea();
Console.WriteLine("Area = {0}", Area); } }
using System; class Circle { public static float _PI; int _Radius;
static Circle() { Console.WriteLine("Static Constructor called"); Circle._PI = 3.14F; }
public Circle(int Radius) { Console.WriteLine("Instance Constructor called"); this._Radius = Radius; }
public float CalculateArea() { return this._PI * this._Radius * this._Radius; } }
class Program { public static void Main() { //Circle C1 = new Circle(5); //float Area = C1.CalculateArea();
//Console.WriteLine("Area = {0}", Area);
//Circle C2 = new Circle(6); //float Area = C2.CalculateArea(); //Console.WriteLine("Area = {0}", Area);
Console.WriteLine(Circle._PI); } }
|
|