Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
class Fan
    {
         class Fan
    {
        private int speed = 1;
        private bool on = true;
        private double raduis = 5.0;
        private string color = "blue";
 
     
 
        public int spee { get { return speed; } set { speed = value; } }
        public bool o { get { return on; } set { on = value; } }
        public double radu { get { return raduis; } set { raduis = value; } }
        public string colour { get { return color; } set { color = value; } }
 
        public Fan(int speed, bool on, double raduis, string color)
        {
            this.speed = speed;
            this.on = on;
            this.raduis = raduis;
            this.color = color; 
        }
        public Fan(int se)
        {
            speed = se;
        }
        public Fan(int se , bool t )
        {
            speed = se ;
            on = t;
        }
        public Fan(int se, bool t , double r)
        {
            speed = se;
            on = t;
            raduis = r;
        }
        public Fan(int seo, bool to, double ro, string ce)
        {
            speed = seo;
            on = tp;
            raduis = ro;
            color = ce;
        }
        public string DisplayFan()
        {
            String printme = null;
 
            if (fan.on = true)
            {
                printme = ("Speed: " +  get.spee() + " Color: " + fan.color + " Radius: " + fan.radius);
            }
            if (fan.on = false)
            {
                printme = ("Color: " + fan.color + " Radius: " + fan.radius + " Fan is Off");
            }
 
            return (printme);
 
        }
 
        }
     static void Main(string[] args)
        {
            Fan f1 = new Fan();
            f1.spee(3);
            f1.radu(10.0);
            f1.colour("Yellow");
            f1.DisplayFan(true);
 
            Fan f2 = new Fan();
            f2.spee(1);
            f2.radu(5.0);
            f2.colour("blue");
            f2.DisplayFan(false);
        }
    } 
 
    }
 
C# error:
already defines a member called 'Fan' with the same parameter types"
Posted 17-Dec-12 3:46am
Edited 20-Dec-12 21:01pm
v4
Comments
lukeer at 21-Dec-12 5:32am
   
I assume this is the second time you ask this question, re-phrased. If it's the other way round, same applies nonetheless: Don't post the same question again. Use the "Improve question" link instead to provide further information. It helps keeping the topic together.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Isn't it self explaining ..
 
public Fan(int seo, bool to, double ro, string ce)
{
speed = seo;
on = tp;
raduis = ro;
color = ce;
}
 
and
 
public Fan(int speed, bool on, double raduis, string color)
{
this.speed = speed;
this.on = on;
this.raduis = raduis;
this.color = color;
}
  Permalink  
Comments
CHill60 at 17-Dec-12 10:05am
   
Or to put it another way ...
Each overload of a function must have a unique signature so the compiler can determine which one you actually meant to call.
You have two functions both with (int, bool, double, string) signature. Luckily for you they appear to trying to do the same thing
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Look at your code, you have the following constructors:
        public Fan(int speed, bool on, double raduis, string color)
        {
            this.speed = speed;
            this.on = on;
            this.raduis = raduis;
            this.color = color; 
        }
 
// 3 others removed for clarity

        public Fan(int seo, bool to, double ro, string ce)
        {
            speed = seo;
            on = tp;
            raduis = ro;
            color = ce;
        }
You cannot have two with the same signature, remove the one that you do not want.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Nirav Prabtani 384
1 OriginalGriff 289
2 Sergey Alexandrovich Kryukov 225
3 _Amy 195
4 Kumarbs 144
0 OriginalGriff 7,799
1 Sergey Alexandrovich Kryukov 6,966
2 Maciej Los 3,994
3 Peter Leow 3,708
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100