Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Chrtran in .NET
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01360482
Message ID:
01360491
Views:
48
This message has been marked as the solution to the initial question of the thread.
>Hi everybody,
>
>What would be the equavalent of chrtran function in .NET ? Calling multiple replace methods?
>
>Thanks in advance.

http://foxcentral.net/microsoft/VFPToolkitNET.htm

Here is what the VFP Toolkit for .NET developers wrote:
/// <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;
		}
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform