View Single Post
  #2 (permalink)  
Old July 27th, 2011, 03:34 PM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts

That's covered briefly in Appendix Q, "Other Format Specifiers" on page 1105-6.

The quick explanation is that the method replaces the placeholders with the parameters that follow. For example:

Dim txt As String = String.Format("There are {0} players", num_players)
If num_players is a variable holding the value 9, then this builds the string:

There are 9 players
You can also add an alignment and format specifier if you like.

Let me know if you have specific questions about this. It isn't covered too much in the book. Often it's just as easy to compose strings using concatenation instead of String.Format.

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)

Last edited by Rod Stephens; July 27th, 2011 at 03:46 PM..
The Following User Says Thank You to Rod Stephens For This Useful Post:
eightbits2011 (July 28th, 2011)