Why are C#/.Net strings length-prefixed and null terminated?

前端 未结 5 812
名媛妹妹
名媛妹妹 2021-02-12 12:34

After reading What's the rationale for null terminated strings? and some similar questions I have found that in C#/.Net strings are, internally, both length-prefixed and nul

5条回答
  •  梦毁少年i
    2021-02-12 13:26

    Best guess is that finding the length is constant (O(1)) compared to traversing it, running in O(n).

提交回复
热议问题