Skip to content

Files

Latest commit

 

History

History
36 lines (27 loc) · 785 Bytes

File metadata and controls

36 lines (27 loc) · 785 Bytes

Pattern: Missing use of strongly-typed Append()/Insert()

Issue: -

Description

Append and Insert provide overloads for multiple types beyond String. When possible, prefer the strongly-typed overloads over using ToString() and the string-based overload.

Example of incorrect code:

class Test
{
    int _value;
    public void Log(StringBuilder destination)
    {
        destination.Append("Value: ").Append(_value.ToString()).AppendLine();
    }
}

Example of correct code:

class Test
{
    public void Log(StringBuilder destination)
    {
        destination.Append("Value: ").Append(_value).AppendLine();
    }
}

Further Reading