/// <summary> /// Replaces each character in a character expression that matches a character /// in a second character expression with the corresponding character in a /// third character expression /// </summary> /// <example> /// Console.WriteLine(ChrTran("ABCDEF", "ACE", "XYZ")); //Displays XBYDZF /// Console.WriteLine(ChrTran("ABCD", "ABC", "YZ")); //Displays YZD /// Console.WriteLine(ChrTran("ABCDEF", "ACE", "XYZQRST")); //Displays XBYDZF /// </example> /// <param name="cSearchIn"> </param> /// <param name="cSearchFor"> </param> /// <param name="cReplaceWith"> </param> public static string ChrTran(string cSearchIn, string cSearchFor, string cReplaceWith) { string lcRetVal = cSearchIn; string cReplaceChar; for(int i=0; i< cSearchFor.Length; i++) { if(cReplaceWith.Length <= i) cReplaceChar = ""; else cReplaceChar = cReplaceWith[i].ToString(); lcRetVal = StrTran(lcRetVal, cSearchFor[i].ToString(), cReplaceChar); } return lcRetVal; }