Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Chrtran in .NET
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01360482
Message ID:
01360491
Vues:
49
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform