• Home
  • About
  • Streaming

xneuron

eXtreme Neuron

Feeds:
Posts
Comments

String.Format() In JavaScript As In C#

September 29, 2006 by bnma

This is a cool script that gives the same effect as the C# string formating with multiple parameters. Check it out:

function format(str)

{

  for(i = 1; i < arguments.length; i++)

  {

    str = str.replace(‘{‘ + (i – 1) + ‘}’, arguments[i]);

  }

  return str;

}

Example: <font color=”#008000″>greeting = format(‘Hello {0} & {1} ‘, ‘John’, ‘Jane’);</font>

Posted in JavaScript, Uncategorized | No Comments Yet

  • Pages

    • About
    • Streaming
  • c

  • Top Posts

    • Copy Directory And Its Content To Another Directory In C#
    • String.Format() In JavaScript As In C#
    • Convert an ArrayList of strings to a string[] array
    • Deserialize XML string
    • Reusable Data Layer In C#
    • X509 Certificate Installation
    • Move Items From One ListBox To Another
    • Launch Cassini Using Command Line
    • Loop Through A Comma Delimited String In SQL
    • Page Postbacks And Client Callbacks
  • Recent Posts

    • Url Validation In Javascript
    • Script To Search Text In Database
    • Launch Cassini Using Command Line
    • Max File Size Upload In ASP.Net
    • File MIME Type Using C#
  • Archives

    • June 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • October 2008
    • August 2008
    • May 2008
    • April 2008
    • February 2008
    • December 2007
    • October 2007
    • September 2007
    • April 2007
    • January 2007
    • November 2006
    • October 2006
    • September 2006
  • Blog Stats

    • 69,240 hits
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.com
  • Watch videos at Vodpod and other videos from this collection.

Blog at WordPress.com.

Theme: Mistylook by Sadish.