我编写了以下方法来从字符串中删除括号中的命名空间.
我想尽快做到这一点.
有没有办法加快以下代码?
using System; namespace TestRemoveFast { class Program { static void Main(string[] args) { string[] tests = { "{http://company.com/Services/Types}ModifiedAt","{http://company.com/Services/Types}CreatedAt" }; foreach (var test in tests) { Console.WriteLine(Clean(test)); } Console.ReadLine(); } static string Clean(string line) { int pos = line.IndexOf('}'); if (pos > 0) return line.Substring(pos + 1,line.Length - pos - 1); else return line; } } }