string-formatting

How can I write consecutive named files in Java?

I have a method for saving a File, but I don't know how to save files with consecutive names such as file001.txt, file002.txt, file003.txt, filennn.text How can I achieve this? ...

Date.ToShortDateFormat() uses wrong locale sometime?

I converted my VS 2008 project into vs 2010 but kept it on .NET 3.5 framework. I don't set my locale anywhere within the app. I've got a couple on computers running windows 7 and XP and both have the region set to EN-AU. Sometime my app returns the short date format like MM/dd/YY (EN-US). As soon as you quit it and start again it reve...

C#: What's the String.Format form of this?

Can someone convert this easy to write (and read) string formatting routine into the "proper" String.Format equivalent code? Int32 power; Single voltage; Int32 kVA; Double powerFactor; powerFactor = power / kVA; label1.Text = DateTime.Now.ToString() + ": " + power.ToString() + "W, " + voltage.ToString() + "V "+ ...

Can printf() produce "-.5" for the value (-0.5)?

i.e. can printf be told to ignore zero when it precedes the decimal point? ...

Clever way to append 's' for plural form in .Net (syntactic sugar)

I want to be able to type something like: Console.WriteLine("You have {0:life/lives} left.", player.Lives); instead of Console.WriteLine("You have {0} {1} left.", player.Lives, player.Lives == 1 ? "life" : "lives"); so that for player.Lives == 1 the output would be: You have 1 life left. for player.Lives != 1 : You have 5 lives lef...

Substring error though not using substring.

I have the following code: public static long CreateVendorsEmailJob(List<Recipient> recipients, string subject, string body) { long emailJobId; using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString)) { connection.Op...

Custom formated string does not display 0

I have a data table bound to a data grid view, one of the columns is a list of int32s. What I would like is to have the column display the number with the word minutes after it. I used the cell style builder and in the format i put # Minutes, this works great however rows that have a 0 value does not display anything in the # placeholder...

How to use an "&" character in a C# button text property to display properly

Hello, My C# code is: Button button; button = new Button(); button.Text = "B&C"; this.Controls.Add(button); But when I run this code the button on my form displays BC (and the C is usually underlined). I know that I can set it to B&&C to get my button text to come out as B&C but the users of my app...

Is there any PHP or JavaScript math expression formatters (which adds brackets) ?

Google Calculator formats math expressions this way: 2+2/2 ---> 2 + (2 / 2) 2+2/2*PI ---> 2 + ((2 / 2) * PI) In others words - it adds brackets. Is there any similar PHP or JavaScript solutions to do the same thing? ...

What formatter pattern should I use to get '00123', '00001' strings from numbers '123' and '1' correspondingly?

I need to format numbers in a way that they should be preceded with zeros to contain 5 digits. I don't get how to create patterns for java formatter. I tried %4d but it doesn't adds zeros. ...

Populating multiple printf format placeholders with same value

Using .NET string formatting you can plug the same value into a format string multiple times: Console.Write("{0}{0}{0}", 1) //prints "111" Is there any way to do this with printf-style formatting, supplying the value only once? ...

Negative currency number XAML

Hi, I have a little problem with the current format of my negative currency number. Here's a screenshot resuming my situation. This is how I'm using the StringFormat in my binding. (BTW, I tried only {0:C}) As expected The current settings of my computer for the negative currency number 4. The result when I'm running my application ...