D
David Lau
I am sorry that you can't override operator= in C#.
Simon Trew said:If the poster is in China (.cn address) the clock may be correct.
Ashish said:Code in C++or just override equals in C#
Ashish
Chad Myers said:You cannot override/overload or otherwise modify
the assignment (=) or new operators in .NET.
There is specific logic that .NET uses for assignment
that is required for the memory management and
garbage collection.
I think what you may want is to override the
implicit and explicit cast operator.
For example:
MyFancyNumberClass mfnc = new MyFancyNumberClass():
// implicit cast
int foo = mfnc;
If you wrote MyFancyNumberClass and you wanted
people to copy it to an int, you'd use the
implicit cast operator to convert mfnc to an
integer.
You can also override explicit casts:
int foo = (int) mfnc;
-c