By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Getting reference to left argument of assignment operator

P: n/a
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.
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

"Mike" wrote:
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.
Jun 27 '08 #2

P: n/a
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

"Family Tree Mike" wrote:
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.

"Mike" wrote:
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.
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.