Why doesn't StringBuilder have IndexOf method?

前端 未结 4 1166
感动是毒
感动是毒 2020-12-10 11:14

I understand that I can call ToString().IndexOf(...), but I don\'t want to create an extra string. I understand that I can write a search routine manually. I just wonder why

4条回答
  •  情歌与酒
    2020-12-10 11:40

    Calling ToString() on a StringBuilder doesn't create an extra object, confusingly. Internally, StringBuilder stores a String object, for performance; calling ToString() simply returns that object.

提交回复
热议问题