468,490 Members | 2,568 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,490 developers. It's quick & easy.

How do I use a curly brace within a string passed to String.Format?

How do I use a curly brace within a string passed to String.Format?
I want to pass a string that includes a curly brace, but that curly
brace is not being used to indicate a replacable format parameter.

Ex: Debug.Writeline(String.Format("{ts '{0:yyyy-MM-dd hh:mm}'}",
Date.Now)

Thanks.

-Jason Kendall
Ja**********@hotmail.com
Nov 20 '05 #1
4 5925
Jason Kendall wrote:
How do I use a curly brace within a string passed to String.Format?
I want to pass a string that includes a curly brace, but that curly
brace is not being used to indicate a replacable format parameter.

Ex: Debug.Writeline(String.Format("{ts '{0:yyyy-MM-dd hh:mm}'}",
Date.Now)


From the docs for String.Format:
"To specify a single literal brace character in format, specify two leading
or trailing brace characters; that is, "{{" or "}}"."

--
Sven Groot

http://unforgiven.bloghorn.com

Nov 20 '05 #2
I know your first thought must have been "Jeez! RTFM."
Let me assure you that I did, but didn't see this reference. I shall
now go back and see what I missed.

Thanks!

On Wed, 19 May 2004 19:18:43 +0200, "Sven Groot" <sv*******@gmx.net>
wrote:
Jason Kendall wrote:
How do I use a curly brace within a string passed to String.Format?
I want to pass a string that includes a curly brace, but that curly
brace is not being used to indicate a replacable format parameter.

Ex: Debug.Writeline(String.Format("{ts '{0:yyyy-MM-dd hh:mm}'}",
Date.Now)


From the docs for String.Format:
"To specify a single literal brace character in format, specify two leading
or trailing brace characters; that is, "{{" or "}}"."


Nov 20 '05 #3
* Jason Kendall <Ja**********@hotmail.com> scripsit:
How do I use a curly brace within a string passed to String.Format?
I want to pass a string that includes a curly brace, but that curly
brace is not being used to indicate a replacable format parameter.

Ex: Debug.Writeline(String.Format("{ts '{0:yyyy-MM-dd hh:mm}'}",
Date.Now)


Enter "String.Format", place the caret on "Format" and press F1. Select
one of the overloaded versions of this method (for example, the fist in
the list) and read the documentation.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Jason,
Its not obvious where {{ & }} are documented...

A good reference on what is allowed in String.Format & other format
parameters is:

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

For {{ & }} specifically:

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

The first link includes numeric, DateTime, Enumeration & customizing...

Hope this helps
Jay

"Jason Kendall" <Ja**********@hotmail.com> wrote in message
news:dv********************************@4ax.com...
I know your first thought must have been "Jeez! RTFM."
Let me assure you that I did, but didn't see this reference. I shall
now go back and see what I missed.

Thanks!

On Wed, 19 May 2004 19:18:43 +0200, "Sven Groot" <sv*******@gmx.net>
wrote:
Jason Kendall wrote:
How do I use a curly brace within a string passed to String.Format?
I want to pass a string that includes a curly brace, but that curly
brace is not being used to indicate a replacable format parameter.

Ex: Debug.Writeline(String.Format("{ts '{0:yyyy-MM-dd hh:mm}'}",
Date.Now)


From the docs for String.Format:
"To specify a single literal brace character in format, specify two leadingor trailing brace characters; that is, "{{" or "}}"."

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by deko | last post: by
8 posts views Thread by Ken in Melbourne Australia | last post: by
5 posts views Thread by Steve | last post: by
4 posts views Thread by JavaGeekRoyR | last post: by
5 posts views Thread by krbyxtrm | last post: by
6 posts views Thread by Bryan Parkoff | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.