Expand Null Coalescing Operation (C#)
In This Article
Converts a null coalescing operation to an equivalent ternary expression.
#Availability
Available from the context menu or via shortcuts:
- when the edit cursor, or caret is on a statement that uses the ?? operator.
#Notes
- This refactoring is the functional opposite of Compress to Null Coalescing Operation (C#).
#Example
private string GetMessage(string text)
{
return (│text ?? "null");
}
Result:
private string GetMessage(string text)
{
return (│text != null ? text : "null");
}
#Screenshot
See Also