We all know that strings
are immutable and StringBuilder is mutable
. Right. Then why does its methods returns a StringBuilder
object. Should they all not be void methods?
Why this
public StringBuilder Append(bool value)
and not
public void Append(bool value)
Any example explaining use of this would be great.
It's called a "fluent interface". It allows you to chain together calls by repeated dot notations.
return new StringBuilder()
.Append("Hello, ")
.Append("world!")
.ToString();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With