In my app I parse a value from xml (string) to a double.
The value in the xml happens to have the dot as a fraction seperator whereas the system takes the current system settings and can have a different separator (dev system takes the comma for example).
Is there a way to tell double.TryParse() the dot is the fraction separator?
Should...
I have a class that represents credit card details. To represent valid from and expiration months and years I am using four properties of type int:
public int ValidFromMonth { get; set; }
public int ValidFromYear { get; set; }
public int ExpiresEndMonth { get; set; }
public int ExpiresEndYear { get; set; }
I am XML Serializing this c...
I'm trying to parse a string that was generated by an NSDateFormatter using another NSDateFormatter with the same format.
Rather than trying to make that previous sentence make sense, here's some code:
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"MMM dd, YYYY HH:mm"];
NSDate *now = [[NSDate alloc] ...
I'm fairly new to C#, and trying to figure out string insertions (i.e. "some {0} string", toInsert), and ran across a problem I wasn't expecting...
In the case where you have two constructors:
public MyClass(String arg1) { ... }
public MyClass(String arg1, String arg2) { ... }
Is it possible for me to use the first constructor with ...
I am using Qt and want to print a data value (double) in a label; however, the trailing zeros are lopped off. I know in C I can use printf("%0.1f", data) to preserve the trailing zeros.
I looked at QString's arg function but that only allows the overall field width to be set. setNum and number each allow the precision to be set but tha...
How do I write a function that formats a string with decimals digits, without trailing 0's or unnecessary 9's? Given that decimals is 2, here's what I expect:
0.999 -> 1.0
0.99 -> 0.99
1.01 -> 1.01
1.001 -> 1.0
123 -> 123.0
0 -> 0.0
0.1 -> 0.1
(negatives as you'd expect)
Here's what I have so far, but it's pretty ugly code. Is ther...
What I need to be able do is format data in a variable, like so:
format: xxx-xxx variable: 123456 output: 123-456
The problem is I need to be able to change the format, so a static solution wouldn't work. I also like to be able to change the variable size, like:
format: xxx-xxx variable: 1234 output: 1-234
All ideas are welcome! Th...
How do I in .NET format a number as percentage without showing the percentage sign?
If I have the number 0.13 and use the format string {0:P0} the output is 13 %.
However I would like to get 13 instead, without having to multiply the number by 100 and using the format string {0:N0}.
(Background: In ASP.NET I have a GridView with a Bou...
For the project that I'm currently on, I have to deliver specially formatted strings to a 3rd party service for processing. And so I'm building up the strings like so:
string someString = string.Format("{0}{1}{2}: Some message. Some percentage: {3}%", token1, token2, token3, number);
Rather then hardcode the string, I was thinking of ...
Essentially I'm looking for something with the same behavior, configuration, logging levels as log4j, but with some of the missing functionality (e.g. formatted logging — see here and here for related SO threads.)
Current nominees are slf4j and log5j.
...
Can I get DateTime.Now to be formatted to
2010-03-01T00:00:00Z
I have used this to format the date part
DateTime.Now.Subtract(new TimeSpan(3001, 0, 0, 0)).GetDateTimeFormats()[5]
...
Hi I am using String.Format("{0:C2}", -1234)
to format numbers.
is always formats the amount to a positive number, while I want it to become $-1234
...
For some reason, ASP.NET code on my server is now returning a format of dd/MM/yyyy instead of MM/dd/yyyy when I use DateTime.ToString("g").
Rather than replacing all the "g" format strings with a concrete format string or CultureInfo argument, is there a way I can just override, across the application, the default "short date" format?
...
Is there any way to create a new
NSString from a format string like @"xxx=%@, yyy=%@" and a NSArray of objects?
In the NSSTring class there are many methods like:
- (id)initWithFormat:(NSString *)format arguments:(va_list)argList
- (id)initWithFormat:(NSString *)format locale:(id)locale arguments:(va_list)argList
+ (id)stringWithForma...
Hi...I have this problem I've been trying to tackle for a while. I have a variable that is 17 characters long, and when displaying the variable on my form, I want it to display the last seven characters of this variable in bold...how do I go about this...I'd really appreciate anybody's insight on this.
...
I'm making a fairly basic rails app and I was wondering what's the best way to strip undesirable html from text field (basically, all I'm looking to preserve are links and no more than 2 linebreaks).
Currently, I'm stripping all html and using simpleformat, since it seems to be less overhead than using RDiscount and Markdown/Textile, b...
Hi,
I'm sure this is an easy one for you geeks:
Say I have a String "ThisIsMyString" and I want to format it like "this_is_my_string" using Ruby.
How do I do that?
Matt
...
What is a culture-invariant way of constructing a string such that the Javascript Date() constructor can parse it and create the proper date object?
I have tried these format strings which don't work (using C# to generate the strings):
clientDate.ToString();
// gives: "11/05/2009 17:35:23 +00:00"
clientDate.ToString("MMM' 'dd', 'yyyy'...
Hi,
I have a string
string str ="Enter {0} patient name";
So I am using using string.format to format that.
String.Format(str, "Hello");
Now if i want patient also to be retireved from some config then i need to change str something like
"Enter {0} {1} name". So it will replace the {1} with second value. the problem for me is that...
Hello,
I've bound my TextBox to a string value via
Text="{Binding AgeText, Mode=TwoWay}"
How can I display string.empty or "" for the string "0", and all other strings with their original value?
Thanks for any help!
Cheers
PS: One way would be a custom ViewModel for the string.. but I'd prefer to do it somehow in the XAML dire...