Sunday, May 24, 2009

String Exercise

/* Custom Project and Libraries Copyright, 2006. Venkat, ISS */

using System;
using System.Collections.Generic;
using System.Text;
using ISS.RV.LIB;

namespace Method
{
class Exercise44
{
static void Main()
{
// Write the Main Program for Exercise44 here...
string s = ISSConsole.ReadString("Enter the input string");
string c1 = ISSConsole.ReadString("Enter the change character");
string c2 = ISSConsole.ReadString("Enter the insert character");

//char c1 = ISSConsole.ReadChar("Enter the change character");
//char c2 = ISSConsole.ReadChar("Enter the insert character");
Console.WriteLine("Change character" + StringType(s,c1,c2));

#region /* Do not remove this or write codes after this */
ISSConsole.Pause();
#endregion
}
static string StringType(string s, string c1, string c2)
{
int i;
//string r;
for (i = 0; i < s.Length; i++)
{
if ( s.Substring(i,1) == c1)
{
s = s.Remove (i,1);
s = s.Insert (i,c2);
}

}
return s;

}
}
}

No comments:

Post a Comment