1

I am working in C# and have come across a statement similar to below:

var dog = anotherDog = someOtherDog;

What exactly is happening here? Is this just assigning the value of one variable to two others?

Thomas
  • 6,291
  • 6
  • 40
  • 69
  • 4
    Why not just create a console application and test it? – sab669 Oct 13 '15 at 17:28
  • 1
    Or a possibly better duplicate: http://stackoverflow.com/questions/17737436 – D Stanley Oct 13 '15 at 18:00
  • @DStanley that's a better duplicate, I think. The unfortunate piece behind the title is that one has to know that question relates, i.e. that "returning from assignment" is relevant. Thanks for the redirect, though; definitely learned something that I did not know previously. – Thomas Oct 14 '15 at 13:26

1 Answers1

2

Yes.

It is like

anotherDog = someOtherDog;
var dog = anotherDog;

You would have to have both anotherDog and someOtherDog to be declared already.

Andreas Reiff
  • 7,961
  • 10
  • 50
  • 104