How to replace occurrences of “-” with an empty string?

后端 未结 6 1829
春和景丽
春和景丽 2021-01-17 09:41

I have this string: \"123-456-7\"

I need to get this string: \"1234567\"

How I can replace occurrences of \"-\" with an empty string?

6条回答
  •  青春惊慌失措
    2021-01-17 09:51

    Use String.Empty or null instead of "" since "" will create an object in the memory for each occurrences while others will reuse the same object.

提交回复
热议问题