Does String.Replace() create a new string if there's nothing to replace?
问题 For example: public string ReplaceXYZ(string text) { string replacedText = text; replacedText = replacedText.Replace("X", String.Empty); replacedText = replacedText.Replace("Y", String.Empty); replacedText = replacedText.Replace("Z", String.Empty); return replacedText; } If I were to call "ReplaceXYZ" even for strings that do not contain "X", "Y", or "Z", would 3 new strings be created each time? I spotted code similar to this in one of our projects. It's called repeatedly as it loops through