StringBuilder for string concatenation throws OutOfMemoryException

后端 未结 8 1649
南旧
南旧 2020-12-06 10:13

We mostly tend to following the above best practice.

Have a look at String vs StringBuilder

But StringBuilder could throw OutOfMemoryException even w

8条回答
  •  一整个雨季
    2020-12-06 10:36

    Well, the question actually is, why do you need to work with strings that long? If you stumble upon this problem, more than likely you should alter your concept.

    This problems affects even the System.String class, so you should rather chunk your input into List< string> and process the data in parallel, which should increase overall performance if written properly.

提交回复
热议问题