Learning Curve…

String.Format…

Posted on: July 12, 2011

String.Format method takes a string that can contain
numeric placeholders wrapped in a pair of curly braces ({}). Then for each numeric value, you supply a
string value as subsequent parameters.If you wanted to format a string with a first and last name, you’d use this code:

VB.NET
Return String.Format(“Hello {0} {1}”, firstName, lastName)

C#
return string.Format(“Hello {0} {1}”, firstName, lastName);

The String.Format method is great to make your strings much more readable. Instead of messy string
concatenation using & or +, you simply define placeholders in the string, and then supply the values at
runtime.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Author

Learning days (Calendar)

July 2011
M T W T F S S
« May   Aug »
 123
45678910
11121314151617
18192021222324
25262728293031

Knowledge Bank (Archives)

I am on Twitter

Blog Stats

  • 520,166 hits

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 43 other followers

%d bloggers like this: