How to remove the particular symbol in a string

Hi,

I am using string which contains some values.

List<string> result = new List<string>();

result = "A1-B1-C1-D1-_F1";

when symbol "-_" found in the result string then it should take only or consider "_".

So the final string would be "A1-B1-C1-D1_F1"

How to replace...
Gani tptTech Lead cum developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
string result = "A1-B1-C1-D1-_F1";
result = result.Replace("-_", "_");

result is now "A1-B1-C1-D1_F1"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaun VermaakTechnical SpecialistCommented:
No, it is a List<string>

List<String> values = new List<string> { "A1-B1-C1-D1-_F1", "A1-B1-C1-D1-_G1", "A1-B1-C1-D1-_H1", "A1-B1-C1-D1-_I1" };
values = values.Select(s => s.Replace("-_", "_")).ToList();

Open in new window

AndyAinscowFreelance programmer / ConsultantCommented:
Actually the question is confusing.
First it says result, as you say, is a List<string> then it shows that result is a string, not a List<string> at all.
AndyAinscowFreelance programmer / ConsultantCommented:
Use the String.Replace function
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.