I have a string which contains multiple items separated by commas :
string RESULT = "D_CA, P_AMOUNT ,D_SH,D_CU,D_TO,D_GO,D_LE,D_NU,D_CO,D_MU,D_PMU,D_DP, P_COMMENT ";
As you can see some elements contain Whitespaces, My object is to remove all the whitespaces, This is my code:
RESULT.Split(',').ToList().ForEach(p =>
if (p.Contains(" "))
{
RESULT = RESULT.Replace(p, p.Trim());
}
});
And this is my result:
"D_CA,P_AMOUNT,D_SH,D_CU,D_TO,D_GO,D_LE,D_NU,D_CO,D_MU,D_PMU,D_DP,P_COMMENT"
it works well, But I ask if there is another more optimized way to get the same result?
