Replace a character with string

Posted on 2008-06-13
Last Modified: 2012-08-13
How can I replace a char with a string like
str.Replace('&', 'and');
Question by:mpaturi1
LVL 16

Expert Comment

ID: 21782120
LVL 31

Accepted Solution

Frosty555 earned 20 total points
ID: 21782141
Seems to me like you've pretty much written the code out already?
string MainString "String Manipulatin"; 

string CorrectString = MainString.Replace("Manipulatin", "Manipulation"); 


MessageBox.Show("Correct string is : " + CorrectString); 

Open in new window

LVL 13

Expert Comment

ID: 21782271
str.Replace("&", "and");

Author Comment

ID: 21852096
I was missing the left hand side of the str.Replace("&","and");
after making change to the code as

str mystring = str.Replace("&", "and");

It was fine.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# TextBox 11 30
c# LinkButton OnClientClick 2 34
Please explain "Multi-Tenant Services" 5 62
how to read json value 2 30
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now