472,328 Members | 1,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Format method of String Type

Hi

Could somebody please explain what the following line of code means

String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1

It's actually the first argument that I don't understand. What is the purpose of "{0}\{1}.{2:00}"? I've been using VB .NET for a year now, and have never come across anything like this

Best Regards
David Morris
Nov 20 '05 #1
4 1559
{0} is a placeholder for the first parameter "c:\". {1} is a placeholder
for the second and {2:00} is a placeholder for the third and the : means
there is format data following and 00 means the format for the param (two
digit number)

Result should be;

c:\\myfile.txt.01

Putting {} around the params for explanation

{c:\}\{myfile.txt}.{01}

"David Morris" <Da**********@compusa.com> wrote in message
news:75**********************************@microsof t.com...
Hi,

Could somebody please explain what the following line of code means?

String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1)

It's actually the first argument that I don't understand. What is the purpose of "{0}\{1}.{2:00}"? I've been using VB .NET for a year now, and
have never come across anything like this?
Best Regards,
David Morris

Nov 20 '05 #2
Thank you very much for the quick & clear explanation!
Nov 20 '05 #3
David,
In addition to Adian's comments. The formatting allowed is explained here:

http://msdn.microsoft.com/library/de...ngoverview.asp

Specifically:

http://msdn.microsoft.com/library/de...formatting.asp

In addition to String.Format: Console.WriteLine & TextWriter.WriteLine also
support format specfiers. Also a number of controls in ASP.NET support a
format property that is used during data binding.

Using a format specifier is very useful for internationalization, as the
place holders in the format string do not need to be in consecutive order.
Const firstName As String = "{0} {1} {2}"
Const lastName As String = "{2}, {0} {1}"

Dim s As String
Dim format As String

format = firstName
s = String.Format(format, "Jay", "B.", "Harlow")

format = lastName
s = String.Format(format, "Jay", "B.", "Harlow")

Where the format (firstName or lastName) is supplied from outside the
routine (such as a resource file (.RESX)). Notice that the three parts of
the name are supplied in the same order to String.Format, however the format
string itself changed for each "format" we wanted to support...

Hope this helps
Jay

"David Morris" <Da**********@compusa.com> wrote in message
news:75**********************************@microsof t.com...
Hi,

Could somebody please explain what the following line of code means?

String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1)

It's actually the first argument that I don't understand. What is the purpose of "{0}\{1}.{2:00}"? I've been using VB .NET for a year now, and
have never come across anything like this?
Best Regards,
David Morris

Nov 20 '05 #4
"David Morris" <Da**********@compusa.com> schrieb
Hi,

Could somebody please explain what the following line of code
means?

String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1)

It's actually the first argument that I don't understand. What is
the purpose of "{0}\{1}.{2:00}"? I've been using VB .NET for a year
now, and have never come across anything like this?


Have you come across the F1 key? ;-) The syntax of the 1st arg is described
in the docs.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris Stiles | last post by:
Is there a human readable dump format for objects ? As opposed to pickling ? It doesn't necessarily have to be XML - in fact i'd prefer if it wasn't...
10
by: Jack | last post by:
Hi, I cannot get the date format correctly in dynamic sql statement, after trying various ways of handling it. I need some help with the date...
6
by: WindAndWaves | last post by:
Hi Gurus In my quest in putting my first javascript together, I am now trying to conquer something that seems trivial, but has taken me hours. ...
3
by: marwa mohamed | last post by:
salamo alikom hi all when i run report that includes image control linked to a field in the table that contains the image path(on the server)and...
1
by: John Chorlton | last post by:
I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd...
7
by: tolisss | last post by:
Hi i have a string like "22/5/2006 12:00:00 p" and i want to create a string like "05/22/06" could someone please
4
by: Fresh_Air_Rider | last post by:
Hi In the "good old" Classic ASP days, I used to stream records from a SQL Server database out to the user's browser in CSV format by using a...
9
by: Alok yadav | last post by:
i am using a webservice in which a method is serach. i use this method which accept a argument of date type in dd/MM/yyyy formate. i have a textbox...
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this:...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.