title: Replace * in string by character in c#. Example p**gra* replace * by rom the output will be program
body: <p>This is the code I'll try. But I got wrong output. Replace * in string by character in c#. Example p**gra* replace * by rom the output will be program.</p>
  <pre><code>namespace Uncensor
  {
      class Program
      {
  
          // &quot;*h*s *s v*ry *tr*ng*&quot;, &quot;Tiiesae&quot; ➜ &quot;This is very strange&quot;
          static string uncensor(string str,string s)
          {
              string s1 = &quot;&quot;;
              int i, j;
              if (str.Contains(&quot;*&quot;))
              {
                 
                 for (i = 0; i &lt; str.Length; i++)
                 {
                      if (str[i] == '*')
                      {
                          for (j = 0; j &lt; s.Length; j++)
                      {
                          
                              s1 = str.Replace(str[i], s[j]);
                          }
                      }
                 }
  
                  return s1;
              }
              else
              {
                  return str;
              }
              
          }
          static void Main(string[] args)
          {
              Console.WriteLine(&quot;Enter  string:&quot;);
              string str = Console.ReadLine();
              Console.WriteLine(&quot;Enter string to be replaced by * :&quot;);
              string s = Console.ReadLine();
  
             string original_text= uncensor(str, s);
              Console.WriteLine(original_text);
  
              Console.Read();
          }
      }
  }
  </code></pre>