In the example below I have a string with pipes |
separating each segment in the string (ie:0123456789). What I am trying to do is replace the pipe character with a string as shown in the example below. How do I accomplish that?
From what I understand the .Replace
can only support (char,char)
or (string, string)
.
Example code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleProject
{
public class Program
{
public static void Main(string[] args)
{
String val1 = "0123456789|0123456789|0123456789|0123456789|0123456789";
val1.Replace('|'.ToString(), "*val1TEST*");
String val2 = "0123456789|0123456789|0123456789|0123456789|0123456789";
val2.Replace("|", "**val2Test**");
Console.WriteLine(String.Format("{0}{1}","val1: ",val1));
Console.WriteLine(String.Format("{0}{1}", "val2: ", val2));
}
}
}
Output From Console
val1: 0123456789|0123456789|0123456789|0123456789|0123456789
val2: 0123456789|0123456789|0123456789|0123456789|0123456789