Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Getting reference to left argument of assignment operator

Reply
 
Old 05-15-2008   #1 (permalink)
Mike


 
 

Getting reference to left argument of assignment operator

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.

My System SpecsSystem Spec
Old 05-15-2008   #2 (permalink)
Family Tree Mike


 
 

RE: Getting reference to left argument of assignment operator

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:
Quote:

> 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.
My System SpecsSystem Spec
Old 05-15-2008   #3 (permalink)
Mike


 
 

RE: Getting reference to left argument of assignment operator

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:
Quote:

> 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:
>
Quote:

> > 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.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Variable assignment and clone or objet reference PowerShell
Assignment Help PowerShell
left side assignment of dual screen desktop Vista General
Using a variable on the left-side of an assignment PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46