:-/
Hey friends I have a problem regarding operator overloading concept in C# language,can
anyone among you please make me understand and supply some example of operator overloading
concept.Some codes can you guys please send me for better understanding and with a brief description..please.

Recommended Answers

All 3 Replies

Hi there,

I suggest you to read first some tutorials and try to understand how it works. If you read through and you don't understand specific parts or have questions, post it here and I'm sure we can help you out :)

Here is a small exemple

public static bool operator ==( User user1, User2 user2 )
                {
                        return ( href1.Username == Href2.Username && href1.Id == href2.Id);
                }

The operators in C# have predefined behaviours when used against the certain types. When you define a custom type, you can also set the behaviour of these operators when applied to that type.

Theres a nice run down of which operators can be overloaded and some examples here.

Shout if you need anything in the link explained :)

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.