-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Performance.AvoidUnneededCallsOnStringRule(2.10)
Sebastien Pouliot edited this page Jan 22, 2011
·
2 revisions
Assembly: Gendarme.Rules.Performance
Version: 2.10
This rule detects when some methods, like Clone(), Substring(0), ToString() or ToString(IFormatProvider), are being called on a string instance. Since these calls all return the original string they don't do anything useful and should be carefully reviewed to see if they are working as intended and, if they are, the method call can be removed.
Bad example:
public void PrintName (string name)
{
Console.WriteLine ("Name: {0}", name.ToString ());
}
Good example:
public void PrintName (string name)
{
Console.WriteLine ("Name: {0}", name);
}
- Prior to Gendarme 2.0 this rule was more limited and named AvoidToStringOnStringsRule
Note that this page was autogenerated (3/17/2011 9:31:58 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!