Replace string with another in DataColumn of DataTable

c#

Solution

In foreach loop you can modify the row by accessing against the column index ("Comments") and use string.Replace to replace `"*"` with `"\n"`

foreach (DataRow drOutput in dtOutput.Rows)
{
     drOutput["Comments"] = drOutPut["Comments"].ToString().Replace('*','\n');
     //your remaining code
}

Problem

I have `DataTable` which retrieves multiple columns and rows. One of its column ("Comments") Contains data `*`. I want replace that character with `\n`. ``` dtOutput = Generix.getTickets(DateTime.Parse("1-1-1900"), DateTime.Now,"",iTicket, "", "", "", "","",iDispatched,uCode); string sOutput = ""; foreach (DataRow drOutput in dtOutput.Rows) { sOutput += ((sOutput == "") ? "" : "~"); foreach (DataColumn dcOutput in dtOutput.Columns) { sOutput += ((sOutput == "") ? "" : "|") + Convert.ToString(drOutput[dcOutput]); } } ``` I am able to merge all columns in one String. But how to replace character with another in store it in Same string as of `"sOutput"`.

Original source