为什么不StringBuilder的有IndexOf方法? [英] Why doesn't StringBuilder have IndexOf method?

查看:392
本文介绍了为什么不StringBuilder的有IndexOf方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以调用toString()。的IndexOf(...),但我不希望创建一个额外的字符串。我知道我可以手工编写一个搜索程序。我不知道为什么这样一个例程不已经在框架存在。

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 such a routine doesn't already exist in the framework.

推荐答案

不幸的是,许多实施了字符串的方法可能已实施的StringBuilder但是却没有这样做。考虑使用扩展方法来添加你所关心的事情。

Unfortunately, many of the methods implemented for String could have been implemented for StringBuilder but that was not done. Consider using extension methods to add what you care about.

这篇关于为什么不StringBuilder的有IndexOf方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆