Getting reference to left argument of assignment operator

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Anyone know of any way to get a reference to the argument to the left (lvalue
I believe it is called) of the assignment operator? I realize you can't
overload the assignment operator in C#, but maybe someone might know some
creative solution using unsafe or interoperable C++ code.
 
Just make a void method that acts upon the result object.

So in code, the following:

x = Foobar(2, 3, 4);

Becomes:

x.Foobar(2, 3, 4);

Then Foobar can reference 'this' or 'me' depending on your language.
 
Thanks for the response, but this is not quite what I'm looking for. I'm
trying to do an implicit cast from one of the built in .Net types to one of
my custom types, but I don't want to have to re-instantiate my custom type
when I do the cast. I want a reference to the object I'm assigning to.

For example:
static public implicit operator RomanNumeral(int value)
{
return new RomanNumeral(value);
}

Rather than new up a RomanNumeral object, I want a reference to the
RomanNumeral I'm assigning to. I'm sure there's no "normal" way to do this.
I'm looking to be atypical.

Thanks, Mike
 
Back
Top