When using string.Format(string, object[]) it throws an exception if string contains more format specifiers ({0}, {1:dd-MM-yyyy} etc.) than object[].Length.
I'd like to also throw an exception if object[].Length contains more specifiers. There seems to be no built-in way to do it, so I'm trying to get the number of format specifiers in ...
I've always seen these header comments in php, and often wondered if some software was used to set them up? I seem to recall JavaDoc or something? But I'm not sure if this is auto generated? Or is this just some type of documentation standard?
The example below is from CodeIgniter:
/**
* CodeIgniter
*
* An open source application...
In PHP, whenever I do something like:
<span>Blah blah HTML</span>
<?= echo $this->foo ?>
<br />
In the source it displays like this:
<span>Blah blah HTML</span>
{$this->foo whatever it is} <br />
Instead of
<span>Blah blah HTML</span>
{$this->foo whatever it is}
<br />
Stuff like this happens all of the time. Inline PHP make...
I've been using VS2005 and VS2008 now for a while, with C#. Without any additional tools I could hit ctrl k + d and the code would nicely reformat. Why doesn't C++ do this?
It's the same Visual Studio after all. Is there a way to enable it?
A second part of this question is related, for those who've been using resharper with C#, is the...
Running a quick experiment related to Is double Multiplication Broken in .NET? and reading a couple of articles on C# string formatting, I thought that this:
{
double i = 10 * 0.69;
Console.WriteLine(i);
Console.WriteLine(String.Format(" {0:F20}", i));
Console.WriteLine(String.Format("+ {0:F20}", 6.9 - i));
Console....
Is there any tool that can (pretty-print) format XML file as well as sort both its elements and attributes?
...
Consider the following:
print 3 ** 333; #Yields 7.6098802313206e+158
My question is simple: How can I disable scientific notation when working with very large numbers? Basically, I'd like to see all the digits dumped to stdout verbatim.
Is this possible?
...
I'm writing an app that needs to output Decimals of varying lengths, and varying scale to strings without the decimal point for writing to a flat file as input to another system. e.g.
12345 -> Length:10, Scale:2 -> 0001234500
123.45 -> Length:10, Scale:2 -> 0000012345
123.45 -> Length:10, Scale:3 ...
Hi,
it's really annoying how C# seems to force you to explicitly name the index of every parameter in String.Format, if you want to add another parameter somewhere you either have to reindex the string or put your new parameter at the end. Is there a way to get C# to do this automatically?
eg (I know this is pointless pedants, it's jus...
I have an array like this:
object[] args
and need to insert those args in a string, for example:
str = String.Format("Her name is {0} and she's {1} years old", args);
instead of:
str = String.Format("Her name is {0} and she's {1} years old", args[0], args[1]);
NOTE: Actually the first line of code worked! But args[1] was missing...
Is there a way to issue a key command to properly format an entire file in VS2008 with CodeRush Express?
...
The eclipse and checkstyle guys of you will surely now this problem: After organizing imports in eclipse with CTRL-SHIFT-o, each import will be on a separate line, without line-wraps.
If you configured checkstyle to warn if you have lines greater than 80 characters, it will probably warn about your imports. Normally I insert newlines at...
How can I show a git log output with (at least) this information:
* author
* commit date
* change
I want it compressed to one line per log entry. What's the shortest possible format for that?
(tried --format=oneline but that does not show the date)
...
I have a character array that contains a phone number of the form: "(xxx)xxx-xxxx xxxx" and need to convert it to something of the form: "xxx-xxx-xxxx" where I would just truncate the extension. My initial pass at the function looks like this:
static void formatPhoneNum( char *phoneNum ) {
unsigned int i;
int numNumbers = 0;
...
I really like the short git log format where I can see author, date and change description like this:
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
Which outputs:
fbc3503 mads Thu Dec 4 07:43:27 2008 +0000 show mobile if phone is null...
ec36490 jesper Wed Nov 26 05:41:37 2008 +0000 Cleanup after [942]: Using timezon...
Hi,
I'm writing a class called StringTemplate, which allows to format objects like with String.Format, but with names instead of indexes for placeholders. Here's an example :
string s = StringTemplate.Format("Hello {Name}. Today is {Date:D}, and it is {Date:T}.",
new { Name = "World", Date = DateTime.No...
I have a number of applications written in different languages (Java, JavaScript, PHP, etc.). Their view/presentation layers display things in various formats: HTML, plain text, etc.
I want to display some textual/numeric data in roughly the same way in each application. Of course, the result would be slightly different depending on the...
I need to format java code to put into a Word document. Are there any programs that will do this with keyword highlighting, etc. ?
...
I am using the standard json module in python 2.6 to serialize a list of floats. However, I'm getting results like this:
>>> import json
>>> json.dumps([23.67, 23.97, 23.87])
'[23.670000000000002, 23.969999999999999, 23.870000000000001]'
I want the floats to be formated with only two decimal digits. The output should look like this:
...
Hi All,
How can I in C language format a number from 1123456789 to 1,123,456,789?
I tried using printf("%'10d\n", 1123456789); but that doesn't work.
Could you advice anything? The simpler the solution the better.
Thanks,
goe
...