Getting reference to left argument of assignment operator

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.
 
F

Family Tree Mike

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.
 
M

Mike

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top