While I was working on some of older code in C#, I encountered a code which irked me.
Without much ado, it goes something like this:
private string foo(string _text)
{
/* some manipulation on _text */
return _text = Server.HtmlDecode(_text);
}
It's the last line which irks me; I'm from C background, and I can understand that the code is in effect trying to return a decoded _text variable. Also the value of an assignment operator is the left operand, so I can see it.
Yet I still find it irksome.
Is it a ordinate practice in C# that I need to get accustomed to?
To me the last line should simply be
return Server.HtmlDecode(_text);
and not be an assignment expression. Is there a deeper C# feature which I'm not aware of?