+ 2

Why can't the asignment operator be overloaded? (C#)

That's my question. (I'm talking C#-wise only)

24th Aug 2017, 10:31 PM
Belegor son of Talagor
Belegor son of Talagor - avatar
1 Réponse
+ 5
First, lets talk about memory management wise. Whenever you define a class and its members, you are defining the object's behaviour. (aka how they should work) But when you create a variable, you are referring to does objects to create it. (aka reference to an object) One example is "int i = 7;". If you know your stuff well, you would realised that "int" is actually a class, try this instead : "Int i = new Int(7);" and it will work. Hence this is what I meant. You can take a look at the link here: He roughly explains the same thing: https://stackoverflow.com/questions/599367/why-can-not-be-overloaded-in-c I only explained the stuff that you might not understood in the link. Also, you can overload operations applied to objects, but not to references. As stated in the link.
25th Aug 2017, 4:10 AM
Wen Qin
Wen Qin - avatar