Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Check for empty string using length property of the string variable

2.00/5 (1 vote)
23 Jun 2010CPOL 11.2K  
Most of the developers use string.Empty to check the empty string. Instead we can check and compare the length property is zero to know the string value is empty or not.
This will increases the performance :thumbsup:

Example:

string empName = txtEmployeeName.Text;

if(empName.Length <= 0)
Response.Write("Employee name is empty");

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)