hey guys,
I`m trying to overload operator = in my class in windows application`s form , I`m not sure what is my problem,would you take a look at my code?

public struct Customer
{
    // Public members
   // public string Name;
    public string Name;
    public string ID;
    public string Address;
    public string Hour;
   

   public  Customer operator +(Customer ob)
    {
        this.Name = ob.Name;
        this.ID = ob.ID;
        this.Address = ob.Address;
        this.Hour = ob.Hour;
return *this;
    }
}

Weuw heavy! I am afraid you cannot overload the = operator.
Think about it. Would it make any sence to do that?
You can overload the + operator for Customer. But then again what would be the meaning of Customer A + Customer B.
If you want to assign A to B, just use A=B.

hey guys,
I`m trying to overload operator = in my class in windows application`s form , I`m not sure what is my problem,would you take a look at my code?

Your problem is really just that you're trying to write C++ instead of C#.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.