There is a smarter way of avoiding null values in string assignment. Many of us use Ternary, Format etc. to handle this.


string studentHobbies = (txtHobbies.Text != null) ? txtHobbies.Text : string.Empty;


can be written smartly using null-coalescing operator (??) as-

string studentHobbies = txtHobbies.Text ?? string.Empty;