Why is "someString += AnotherString = someString;" valid in C#

Viewed 572

I was writing some code today and was mid line when I alt-tabbed away to a screen on my other monitor to check something. When I looked back, ReSharper had colored the 3rd line below grey with the note "Value assigned is not used in any execution path".

var ltlName = (Literal) e.Item.FindControl("ltlName");
string name = item.FirstName;
name += 

ltlName.Text = name;

I was confused; surely this code can't compile. But it does, and it runs too. The line "name +=" has no effect (that I could tell) on the string. What's going on here?

(Visual Studio 2008, .NET 3.5)

6 Answers
Related