I have this string: \"123-456-7\"
I need to get this string: \"1234567\"
How I can replace occurrences of \"-\" with an empty string?
string r = "123-456-7".Replace("-", String.Empty);
For .Net 1.0 String.Empty will not take additional space on the heap but "" requires storage on the heap and its address on the stack resulting in more assembly code. Hence String.Empty is faster than "".
Also String.Empty mean no typo errors.
Check the What is the difference between String.Empty and “” link.