Generally I'd avoid using the return value of an assignment as it can all too easily lead to had to spot bugs. However, there is one excellent use for the feature as hopefully illustrated below, lazy initialization:
class SomeClass
{
private string _value;
public string Value { get { return _value ?? (_value = "hello"); } }
}
As of C# 6, this can be expressed using the =>
notation:
class SomeClass
{
private string _value;
public string Value => _value ?? (_value = "hello");
}
By using the ?? notation and the return value from the assignment, terse, yet readable, syntax can be used to only initialize the field and return it via a property when that property is called. In the above example, this isn't so useful, but within eg facades that need to be unit tested, only initializing those parts under test can greatly simplify the code.