I've kinda followed this format in a lot of places
- private void testing()
-
{
-
string szFirst = tbFirstName.Text;
-
bob.Trim(); // By definition "removes all trailing and leading whitespace characters"
-
if (string.IsNullOrEmpty(szFirst )) { /* do nothing */ }
-
else
-
{
-
// do somthing here
-
}
-
}
-
If you only trim the start, you don't catch trailing whitespace.
If you only trim ' ', you only trim out the ASCII 32 {space] character, not all forms of whitespace.
As for trimming the space between first and last name...
Use different boxes then combine them if you need a combined field.
In the real world not everyone is "John Smith". You have to take into consideration people with hyphenated to two part last names... someone who under "name" would enter first, middle, last... or people who might enter "last, first i."... So guide them with a well thought-out form that doesn't leave room for interpretation. Besides, you're going to want their last name as a separate field at some point so you can sort data, or their first name by it self for a friendly salutation.