If you always know that you want to have no spaces, you can call trim as soon as you save off the value:
You don't need to check for null here as you know the Text property of a textbox will never return null.Code:string lastName = textbox.Text.Trim(); if (lastName != String.Empty) { ... }




Reply With Quote