Re: string.Format and curly braces

2011-02-02 Thread Grant Maw
Does this help? http://geekswithblogs.net/jonasb/archive/2007/03/05/108023.aspx On 3 February 2011 15:42, Greg Keogh wrote: > Back to coding ... I diagnosed an app crash today caused by an argument > to string.Format having curly braces inside it. I was doing something like > string.Format("R

RE: string.Format and curly braces

2011-02-02 Thread David Kean
You don't have to escape arguments, for example, below shouldn't crash on any version of .NET . We you perhaps instead passing user input as the format string instead? That you will have to escape. From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Greg Keo

Re: string.Format and curly braces

2011-02-02 Thread mike smith
It reminds me of that old c nemesis, scanf and its ilk. Even printf could get confused at times if you fed it the wrong parameters. On Thu, Feb 3, 2011 at 4:59 PM, David Kean wrote: > You don’t have to escape arguments, for example, below shouldn’t crash on > any version of .NET . > > > > We

RE: string.Format and curly braces

2011-02-02 Thread Greg Keogh
>You don't have to escape arguments, for example, below shouldn't crash on any version of .NET . >We you perhaps instead passing user input as the format string instead? That you will have to escape. Oops! Sorry, you're right, I had it backwards. The format string contains "{Intention}" not th

Re: string.Format and curly braces

2011-02-03 Thread mike smith
Re-write all your Format calls to preFormat, which does a sanity check on parameters? It'd let you do a global search replace thru your code, and give you one spot to add escaping of the braces if the contents of the braces didn't meet a pre-determined string. On Thu, Feb 3, 2011 at 5:34 PM, Gr

RE: string.Format and curly braces

2011-02-03 Thread David Kean
, 2011 4:34 PM To: ozDotNet Subject: Re: string.Format and curly braces Re-write all your Format calls to preFormat, which does a sanity check on parameters? It'd let you do a global search replace thru your code, and give you one spot to add escaping of the braces if the contents of the b

Re: string.Format and curly braces

2011-02-03 Thread Noon Silk
On Fri, Feb 4, 2011 at 12:02 PM, David Kean wrote: > I’m really interested in the scenario where you are passing user input as > the format string – do you have user input with placeholders ({0}) that you > need to fill? His problem is double formatting. Something like: string likes = "Okay: {0

RE: string.Format and curly braces

2011-02-03 Thread Greg Keogh
It's not that simple. The formatting call is deep inside a "general purpose" routine that renders a Silverlight drawing using graphics primitives and it has a feature to construct strings out of pieces of other strings, controlled by an XML config file. I guess I outsmarted myself by creating th