In this article, We will discuss How to use string.IsNullOrEmpty efficiently.
Whenever people do coding at that time they check for null or empty Conditions to handle error like this,
string str="";
if(str == null or str == "" or str==string.Empty)
{
//your code if any
}
else
{
//your code if any
}
But without writing all those codes we can write it in a simple and clean way which is as follows,
string str="";
if(string.IsNullOrEmpty(str))
{
//your code if any
}
else
{
//your code if any
}
The string.IsNullOrEmpty can check null and empty condition Simultaneously and which is much faster as compared to Check multiple condition.
0 comments:
Post a Comment