You are on page 1of 1

using System;

namespace ConsoleApplication2

class Program

static void Main(string[] args)

string str = "This is a Cow";

Console.WriteLine("Before Replacing is : "+str);

char[] toChangeChar = str.ToCharArray();

int charIndex = str.IndexOf(" is ");

if (charIndex != -1)

toChangeChar[charIndex++] = ' ';

toChangeChar[charIndex++] = 'w';

toChangeChar[charIndex++] = 'a';

toChangeChar[charIndex] = 's';

string ustr = new string(toChangeChar);

Console.WriteLine("After Replacing Is as Was: "+ustr);

Console.ReadKey();

You might also like