string.format Questions

2

Solved

Given the following C# code: var dt = DateTime.Now; Console.WriteLine("{0:MM/dd/yy} ... {1}", dt, string.Format("{0:MM/dd/yy}", dt)); ... when the short date (under Windows 7, Control Panel -&gt...
Roughrider asked 18/6, 2014 at 5:25

1

Solved

I was trying to print a truth table for Boolean expressions. While doing this, I stumbled upon the following: >>> format(True, "") # shows True in a string representation, same as str(Tru...

4

Solved

What is an elegant way to pull out common formats (e.g. datetime) for string.format into accessible constants? Ideally I would like to do something like the following, but I get the below error wh...
Cristionna asked 31/3, 2014 at 19:20

3

Solved

Is it possible to use Python's str.format(key=value) syntax to replace only certain keys. Consider this example: my_string = 'Hello {name}, my name is {my_name}!' my_string = my_string.for...
Chery asked 29/10, 2013 at 4:1

1

Solved

Wondering if it is possible to combine both a single string and varargs string in a String.format(), like this: String strFormat(String template, String str, String... moreStrs) { return String....
Udell asked 29/7, 2013 at 22:57

4

Solved

I'm no doubt missing something really obvious here but I can't figure it out. Any help would be appreciated. The mistake is coming from here: package B00166353_Grades; public class Student{ Stri...
Tetrahedral asked 26/7, 2013 at 12:22

1

Solved

I have a few C# apps that do logging, and the Output method has an overload to accept the message and a StreamWriter, and another overload with an additional parameter for a params array. An exampl...
Galenical asked 14/5, 2013 at 15:11

4

Solved

In C, the printf() statement allows the precision lengths to be supplied in the parameter list. printf("%*.*f", 7, 3, floatValue); where the asterisks are replaced with first and second values, ...
Nephron asked 11/9, 2012 at 18:31

2

Solved

Given this: string msg = string.Format("Duckbill {0} Platypus has not been loaded. Fetch Duckbill {1}'s Platypus then continue.", userDuckbill, userDuckbill); ...would it suffice to do this inst...
Ijssel asked 12/4, 2013 at 16:32

13

Solved

Looking for an implementation for C++ of a function like .NET's String.Format. Obviously there is printf and it's varieties, but I'm looking for something that is positional as in: String.Format...
Hagi asked 20/1, 2009 at 18:52

7

Solved

Why would anyone use String.Format in C# and VB .NET as opposed to the concatenation operators (& in VB, and + in C#)? What is the main difference? Why are everyone so interested in usin...
Giaimo asked 12/1, 2011 at 17:2

2

Solved

Basically I'm realizing that my application is using commas instead of decimals, and i NEVER want to allow this. Anyone know how I can correct? I can't find one thing via google that is to force de...
Jerriejerrilee asked 19/2, 2013 at 0:18

5

Solved

The following code keep giving me error saying Input string was not in a correct format, but I am pretty sure it is right, isn't it? int id = 112; String[] newData = { "1", "2", "21", "rei...
Swarth asked 29/1, 2013 at 0:19

5

I'm reading IP address numbers from database in a int format but I want to show them in IP format like 000.000.000.000 Is it possible using the String.Format method? For e.g.: string str = Str...
Fultz asked 22/2, 2011 at 6:4

2

Solved

Is there any side effect of passing and extra argument to the string.Format function in C#? I was looking at the string.Format documentation at MSDN but was unable to find an answer. E.g.: string s...
Stew asked 30/11, 2012 at 12:51

2

Solved

We have thousands of different log messages coded using the log4net library and string format method calls. One problem with this is that it's only at run time that we get an error if the string f...
Interior asked 19/10, 2012 at 16:48

4

Solved

string.Format has following method signature string.Format(format, params, .., .. , ..); I want to pass custom format each time like string custFormat = "Hi {0} ... {n} "; // I only care about...
Indefensible asked 24/8, 2012 at 15:16

5

Solved

I was wondering if there's a syntax for formatting NULL values in string.Format, such as what Excel uses For example, using Excel I could specify a format value of {0:#,000.00;-#,000.00,NULL}, whi...
Linkwork asked 7/10, 2011 at 14:58

1

Solved

I'm trying to format an Html.EditorFor textbox to have currency formatting, I am trying to base it off of this thread String.Format for currency on a TextBoxFor. However, my text just still shows u...
Gilboa asked 24/5, 2012 at 16:5

5

Solved

Can anyone explain if there is any benefit in either one of the following methods: decimal d = 12.0m; // 1. how I'd have done it myLabel.Text = d.ToString(); // 2. how I saw someone do it today ...
Wainscot asked 1/5, 2012 at 15:40

5

Solved

I have some double values I want to convert to a string with this pattern: 0.xx or x.xx Currently I have try this: double.ToString("#.#0"); What should I add in order to see zero in case my n...
Relate asked 26/3, 2012 at 9:7

7

I would like to do some condition formatting of strings. I know that you can do some conditional formatting of integers and floats as follows: Int32 i = 0; i.ToString("$#,##0.00;($#,##0.00);Zero")...
Evangelinaevangeline asked 30/9, 2008 at 19:6

8

Solved

I think the direct answer to the question is 'No' but I'm hoping that someone has written a real simple library to do this (or I can do it...ugh...) Let me demonstrate what I am looking for with a...
Greenlaw asked 10/12, 2008 at 20:14

2

Solved

I'd like to find results that Name starts with param1, and ends with param2 but my code doesn't work string wmiQuery = string.Format("SELECT CommandLine FROM Win32_Process WHERE Name LIKE '{0}%' A...
Marna asked 7/6, 2011 at 11:23

2

Solved

The compiler has access to the format string AND the required types and parameters. So I assume there would be some way to indicate missing parameters for the varargs ... even if only for a subset ...
Alkali asked 17/1, 2011 at 21:38

© 2022 - 2024 — McMap. All rights reserved.