How to replace a char in string with an Empty character in C#.NET

后端 未结 8 1291
感动是毒
感动是毒 2020-12-13 23:27

I have a string like this:

string val = \"123-12-1234\";

How can I replace the dashes using an empty string in C#.

I mean val

相关标签:
8条回答
  • 2020-12-14 00:09

    I have a latin version of the code of Razvan Dumitru because us use a million indicator even. Offcourse I use a double replace :D

    public static string CleanNumb(string numb) 
    {
        foreach (char c in ".,'´")
           numb = numb.Replace(c, ' ');
    
        return numb.Replace(" ", "");
    }
    
    0 讨论(0)
  • 2020-12-14 00:20

    This seems too simple, but:

    val.Replace("-","");
    
    0 讨论(0)
提交回复
热议问题