1193 Views
I came across an interesting piece of code the other day, something I didn’t even know possible in C# - return a = "hello";. What do you think this line returns?
Join in on a hand-picked round up of the best .NET articles every day.
Curated by our Moderators and Voted up by our Community. Free.
I came across an interesting piece of code the other day, something I didn’t even know possible in C# - return a = "hello";. What do you think this line returns?
It would first assign a to "hello" and then return "hello" because of the assignment operator's chaining effect (i.e. a = b = c = ...).
HTH,
zychr