Skip to main content

Redundant String.Format call

In This Article

CodeRush Classic shows the Redundant String.Format call code issue if a String.Format() call has only one argument.

#Fix

Remove the redundant String.Fromat() call.

#Purpose

Highlights the String.Format() calls, which can be removed to improve code readability.

#Example

public class MyClass
{
    public MyClass(string text)
    {
        _Text = text;
    }
    private string _Text;
    public string GetTextData()
    {
        return string.Format(_Text);
    }
}

Fix:

public class MyClass
{
    public MyClass(string text)
    {
        _Text = text;
    }
    private string _Text;
    public string GetTextData()
    {
        return _Text;
    }
}