Closed gaufung closed 1 month ago
StringBuilder Vs String concatenation
StringBuilder
EndsWith(string) Vs EndsWith(char)
EndsWith(char)
性能比较好
StringIsNullOrWhitespace
性能比 StringIsNullOrEmpty
慢StringIsNullOrWhitespace
\n \n\t
是合法字符,使用 StringIsNullOrEmpty
ToUpper
方法通常比 ToLower
慢Invariant
方法通常比 non-invariant
慢InvariantCultureIgnoreCase
比 OrdinalIgnoreCase
慢, 因为 InvariantCultureIgnoreCase
检查字符串的意义var s1 = = "Straße"; // German for "street"
var s2 ="STRASSE";
string.Equals(s1, s2, StringComparison.InvariantCultureIgnoreCase); //True
string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase); //False
System.Text.Json
在时间和内存消耗上比 Newtonsoft
有更好的表现
https://www.code4it.dev/blog/top-6-string-performance-tips/