Memory Efficiency and Performance of String.Replace .NET Framework

前端 未结 10 1332
天命终不由人
天命终不由人 2020-11-27 16:50
 string str1 = \"12345ABC...\\\\...ABC100000\"; 
 // Hypothetically huge string of 100000 + Unicode Chars
 str1 = str1.Replace(\"1\", string.Empty);
 str1 = str1.Rep         


        
10条回答
  •  误落风尘
    2020-11-27 17:17

    StringBuilder sb = new StringBuilder("Hello string");
    sb.Replace("string", String.Empty);
    Console.WriteLine(sb);  
    

    StringBuilder, a mutable string.

提交回复
热议问题