Link to home
Start Free TrialLog in
Avatar of Akshay Welekar
Akshay Welekar

asked on

type expected error

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Configuration;
using System.Text.RegularExpressions;

namespace enumeration
{

    class Area
    {
        public enum Shape
        {
            Circle,
            Square
        }
        public void AreaShape(int x, Shape shape)
        {
            double area;
            switch (shape)
            {
                case Shape.Circle:
                    area = Math.PI * x * x;
                    Console.WriteLine("Circle Area= " + area);
                    break;
                case Shape.Square:
                    area = x * x;
                    Console.WriteLine("Square Area= " + area);
                    break;
                default:
                    Console.WriteLine("Invalid Input"); break;
            }
        }
    }
    class EnumTest:
    {
        public static void Main(string[] args)
        {
            Area area= new Area();
            area.AreaShape(15,Area.Shape.Circle);
            area.AreaShape(15,Area.Shape.Square);
            area.AreaShape(15,(Area.Shape)1);
            area.AreaShape(15,(Area.Shape)10);
        }
    }

}
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Two problems in code solved