Format

Introductionary
This method to help the developer to format a string with named string. Named string can be instantiated by using Hashtable, and all named string will be replaced with the value assigned to the name.

Parameters
format Type: System.String
A composite format string.

args Type: System.Collections.Hashtable
A Hashtable that contains zero or more values to format.

Return Value
Type: System.String
A copy of format in which the format items have been replaced by the string representation of the corresponding objects in args.

How to Use
Replaces each format item in a specified string with the text equivalent of a corresponding object's value.

Make sure before doing anything, add reference to Rdz.dll, and add in the using directive for Rdz.Utility.

  1. var ht = new Hashtable();
  2. ht.Add("name", "Minion Extra");
  3. ht.Add("address", "underground");
  4. string format = "my name is [[name]] for it called [[name]] to be noted. and address is [[address]].";
  5. txtResult.Text = format.Format(ht);

Declare new instance of Hashtable with IgnoreCase if you need case-insensitive replacement.

  1. var ht = new Hashtable(StringComparer.CurrentCultureIgnoreCase);

Last edited Apr 24, 2013 at 12:19 PM by radityoardi, version 2

Comments

No comments yet.