从字符串中删除空白字符

时间:2022-08-22 13:12:29

String variable stores value as like .. careteam order 4-26-11.csv

字符串变量存储的值类似于... careteam order 4-26-11.csv

i need to trim the value .. in c# as like careteamorder4-26-11.csv - by removing the space ..!

我需要修剪值...在c#中像careteamorder4-26-11.csv一样 - 删除空间..!

how to remove empty space in the string variable ?

如何删除字符串变量中的空格?

2 个解决方案

#1


0  

    public string RemoveSpaceAfter(string inputString)
    {
        try
        {


            string[] Split = inputString.Split(new Char[] { ' ' });
            //SHOW RESULT
            for (int i = 0; i < Split.Length; i++)
            {
                fateh += Convert.ToString(Split[i]);
            }
            return fateh;
        }
        catch (Exception gg)
        {
            return fateh;
        }
    }

#2


44  

string trimmed = "careteam order4-26-11.csv".Replace(" ", string.Empty);

#1


0  

    public string RemoveSpaceAfter(string inputString)
    {
        try
        {


            string[] Split = inputString.Split(new Char[] { ' ' });
            //SHOW RESULT
            for (int i = 0; i < Split.Length; i++)
            {
                fateh += Convert.ToString(Split[i]);
            }
            return fateh;
        }
        catch (Exception gg)
        {
            return fateh;
        }
    }

#2


44  

string trimmed = "careteam order4-26-11.csv".Replace(" ", string.Empty);