parsing arguments in overloading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rizzy Ranger
    New Member
    • Sep 2015
    • 1

    parsing arguments in overloading

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace midq6
    {
        class Program
        {
            const double pi=3.142;
            static void Main(string[] args)
            {
                Program test = new Program();
                test.area(2.0,2.8,4.0,4.9,5.0,3.8);
    
    
            }
    
            public double area(double s) 
            {
                double area = s * s;
                Console.WriteLine("Area of a square: "+ area);
                return area;
            }
            public double area(double l, double w) 
            {
                double area = l * w;
                Console.WriteLine("Area of a rectengle: "+ area);
                return area;
            }
            public double area(double h,double b) 
            {
                double area = 0.5 * h * b;
                Console.WriteLine("Area of a triangle: " + area);
                return area;
            }
            public double area(double r) 
            {
                double area = pi * r * r;
                return area;
            }
        }
    }
    it gives me an error when trying to give arguments in my main method...please help
    Last edited by Rabbit; Sep 8 '15, 04:26 PM. Reason: Fixed code tags
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    First error:
    Code:
    Severity	Code	Description	Project	File	Line
    Error	CS0111	Type 'Program' already defines a member called 'area' with the same parameter types	midq6	...\Projects\midq6\midq6\Program.cs	31

    Second error:
    Code:
    Severity	Code	Description	Project	File	Line
    Error	CS0111	Type 'Program' already defines a member called 'area' with the same parameter types	midq6	...\Projects\midq6\midq6\Program.cs	37
    Third error:
    Code:
    Severity	Code	Description	Project	File	Line
    Error	CS1501	No overload for method 'area' takes 6 arguments	midq6	...\Projects\midq6\midq6\Program.cs	14
    This third error is in the main, and seems pretty clear to /me

    It's claiming it does not know what to do with 6 parameters when doing something with 'area'.

    Comment

    Working...