Is it possible to overload the operators "as" or "is"?

Is this allowed? If not, can this be done inherently by overloading the implicit / explicit conversion operators?

+4
source share
3 answers

Is the "is" and "how" operator overloaded?

No.

If not, can this be done due to overloading of implicit / explicit conversion operators?

No. The "how" and "is" operators tell you what it really is. They do not pay attention to user conversions.

Cm.

http://blogs.msdn.com/b/ericlippert/archive/2009/10/08/what-s-the-difference-between-as-and-cast-operators.aspx

http://blogs.msdn.com/b/ericlippert/archive/2010/09/16/is-is-as-or-is-as-is.aspx

for some thoughts on how and is operators.

+15
source

No. Check this out: Overloaded Operators and All C # Operators

+5
source

No, because they are not operators as such, they are keywords of the language.

Also, I'm not sure if you would overload them and retain the semantics of the language specification? It seems that it can only be used for great evil :)

0
source

Source: https://habr.com/ru/post/1336323/


All Articles