1

Is there anyway to overload a binary operator without have the containing type or using an extension method?

I want to override the == operator between two byte arrays, and hopefully, without an extension method.

Any help is greatly appreciated.

2 Answers 2

2

This is completely impossible; extension operators do not exist.

Sign up to request clarification or add additional context in comments.

Comments

1

Not only is it impossible, but it sounds downright dangerous. This is exactly why they limited operator overloading unlike C++. They give you a lot of the expressiveness that operators allow, but avoid many of the pitfalls that C++ provided.

The number of people that would do this and cause unexpected results for their fellow developers would probably be scary.

Create a method.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.