Home
Do you use String.Empty instead of ""?
  v1.0 Posted at 26/04/2018 7:55 AM by Tiago Araujo

Considering the memory management of .NET Framework String.Empty will get higher performance then using "".

​public string myString
{
get
{
return ;
}
}

Figure: Bad code. Low performance​​

public string myString
{
get
{
return string.Empty;
}
}​

Figure: Good code. Higher performance

We have a program called SSW Code Auditor to check for this rule.​

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments:

    Note: Social Media login for Yotpo is not working in IE or Safari, please use Chrome. We are waiting for Yotpo to fix it.