I am doing some validation on a form and I am checking for empty strings or empty lists.
Is this a proper way to check for an empty string in a text box?
From my understanding this will check to see that the Text field is empty. This also prevents the use of something like the following which does the same thing.Code:if(Textbox.Text == String.Empty)
Which is basically doing like a magic number where I have a literal string in my code.Code:if(Textbox.Text == "")
But how would you do this with a List or Listbox? I am trying to prevent the following where I have a hard coded 0.
Code:if(List.Items.Count == 0)




Reply With Quote