public static double GetArea(enShape shape, double length1 = 0, double length2 = 2) { switch (shape) { case enShape.Rectangle: return(length1 * length2); case enShape.Triangle: return(length1 * length2 / 2.0f); case enShape.Circle: return(Math.PI * Math.Pow(length1, 2)); default: return(0); } /* * if (String.Equals("Rectangle", shape, StringComparison.OrdinalIgnoreCase)) * { * return length1 * length2; * } * else if (String.Equals("Triangle", shape, StringComparison.OrdinalIgnoreCase)) * { * return length1 * length2 / 2; * } * else if (String.Equals("Circle", shape, StringComparison.OrdinalIgnoreCase)) * { * return Math.PI * Math.Pow(length1, 2); * } * * return 0; */ }
public static double GetArea(enShape shape, double length1 = 1, double length2 = 2) { switch (shape) { case enShape.Tri: return(length1 * length2 / 2); case enShape.Rec: return(length1 * length2); case enShape.Cir: return(Math.PI * Math.Pow(length1, 2)); default: return(0); } }