StringBuilder 的 C# String.Substring 等价物?

标签 c# substring stringbuilder

StringBuilder 似乎没有 Substring(start, len) 方法...我在这里缺少什么?

最佳答案

StringBuilder 类有一个特殊版本的 ToString带有两个参数的方法,与 Substring(startIndex, length) 完全相同。

 StringBuilder sb = new StringBuilder("This is a Test");
 string test = sb.ToString(10, 4);
 Console.WriteLine(test);   // result = Test

关于StringBuilder 的 C# String.Substring 等价物?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25274894/

相关文章:

regex - 提取以数字开头和结尾的子字符串

asp.net - 将 ASP.Net GridView HTML 转换为字符串

c# - 从 Windows 移动应用程序获取文件的图标

c# - 在使用 SQL 查询的单元测试中模拟 IDocumentQuery

python pandas 基于列值的子字符串

java - 如何根据给定的输入数字反转字符串中的每个单词?

c# - 使用 StringComparer 和 StringBuilder 来搜索字符串

c# - 是否可以使用 TagLibSharp 从 MP3 文件中删除 Lyrics3v2 标签?

c# - 返回 Id 的通用函数

python - Pandas 子字符串 DataFrame 列