Skip to content

Extend string concatenation operator (&) to support StringBuilder as its left operand #114

@AnthonyDGreen

Description

@AnthonyDGreen

Concatenation is fine for simple cases but we've all had it drilled into us that StringBuilder is the way to go for successively building up large strings, particularly in loops, to avoid creating lots of very large garbage. The problem is that you have to completely change your code to go from one to the other. But, if we extend & to support StringBuilder on the left then most of the code could stay the same using &= and only the declaration of the variable would need to change to reap performance improvements.

In short, StringBuilder & <value> would be defined to be StringBuilder.Append(<value>) and StringBuilder &= <value> would be defined as StringBuilder = StringBuilder.Append(<value>).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions