I know how to check when a string is NullOrWhiteSpace. But i want to make my code shorter. And to return a value if my string is null or empty.
Till now i use this:
string Foo=textbox1.Text;
if(string.IsNullOrWhiteSpace(textbox1.Text);
textbox1.Text="UserName";
Is this possible to return this result using one line of code?
string Foo=textbox1.Text ?? "UserName";
In this example it returns me ""; So it thinks that my textbox it is not null, and it doesnt returns me the result i want. Is there any working example for my case?