How can we prepend strings with StringBuilder?

后端 未结 12 2294
一整个雨季
一整个雨季 2020-12-24 00:22

I know we can append strings using StringBuilder. Is there a way we can prepend strings (i.e. add strings in front of a string) using StringBuilder

12条回答
  •  粉色の甜心
    2020-12-24 00:29

    Using the insert method with the position parameter set to 0 would be the same as prepending (i.e. inserting at the beginning).

    An example is: varStringBuilder.insert(0, "someThing");

    It works both for C# and Java

提交回复
热议问题