Skip to main content

RCS1235: Optimize method call

Properties

PropertyValue
Default SeverityInfo
Minimum language version-

Examples

Example #1

diagnostic.cs
string.Compare(x, y, StringComparison.Ordinal)
fix.cs
string.CompareOrdinal(x, y)

Example #2

diagnostic.cs
string.Compare(x, y, StringComparison.CurrentCulture) == 0
fix.cs
string.Equals(x, y, StringComparison.CurrentCulture)

Example #3

diagnostic.cs
string.Join("", x, z, y)
fix.cs
string.Concat(x, y, z)

Example #4

diagnostic.cs
Debug.Assert(false, "message");
fix.cs
Debug.Fail("message");

Example #5

diagnostic.cs
if (dic.ContainsKey(key))
{
dic[key] = value;
}
else
{
dic.Add(key, value);
}
fix.cs
dic[key] = value;

Applies to