Test if a string is empty in c#
Posted on 2004-08-06
Gonna sound like a really stupid question but I just dont get how to test if string contains any data. In this case I'm casting it from session. Documentation I've read states one should test by the length of string as per below. However when I do this I just get the old "object not set to an instance of an object" error referring to the string.
public class Index : System.Web.UI.Page
private string sString;
private void Page_Load(object sender, System.EventArgs e)
sString = (string) Session["something"];
if(sString.length > 0)
What is the best way to initiate and then test strings?