Reputation: 467
i have a string type variable like a="a,b,c,d";
I want to remove all commas and get new value for a like abcd
.I tried a.Replace(",","")
but it is not working.I am using c# 3.0
Upvotes: 17
Views: 68708
Reputation: 942
Try this instead
a = a.Replace("," , "");
Edit
Your code is correct as far as using Replace() function goes. What you are missing is that Replace() does not modify the original string, it returns a new (updated) string which you should save.
Upvotes: 55
Reputation: 321
a.Replace(",", "");
Works for me, your problem lays else where. Also try this:
= String.Concat(a.Split(','));
Upvotes: 3