string type .NET vs. char array

后端 未结 2 359
闹比i
闹比i 2021-01-11 14:47

I\'ve been working with some programs here at work for about a month now that have a lot of string parsing and such going on. I\'ve been advised to use a char array for thi

2条回答
  •  一整个雨季
    2021-01-11 15:16

    The advantage with char arrays over strings is that you can alter character arrays in place; in C# strings are immutable, and so any change creates a new object on the heap with a changed version of the string. In a char array you can make lots of changes without allocating anything on the heap.

提交回复
热议问题