string.format Questions

5

Solved

I'm trying to use String.Format("{0:c}", somevalue) in C# but am having a hard time figuring out how to configure the output to meet my needs. Here are my needs: 0 outputs to blank 1.00 outputs t...
Kastner asked 12/2, 2009 at 18:36

3

Solved

I have been developing a .NET string formatting library to assist with localization of an application. It's called SmartFormat and is open-source on GitHub. One of the issues it tries to address i...
Enchase asked 21/8, 2011 at 5:40

3

Solved

To concatenate String we often use StringBuilder instead of String + String, but also we can do the same with String.format which returns the formatted string by given locale, format and arguments....
Piotrowski asked 22/5, 2017 at 16:24

4

Solved

I have a line of code, something like: mbar.HealthLabel.text = String.Format("{0:0.0}", _hp); Output is: 2.25 for example. Is it possible to escape a dot from the output string view with String...
Sinnard asked 5/5, 2017 at 10:12

10

Consider the custom toString() implementation of a bean: @Override public String toString() { String.format("this is %s", this.someField); } This yields this is null if someField is null. Is t...
Ungrateful asked 5/12, 2013 at 15:59

1

Solved

I have a string.format issue ... I'm trying to pass my invoice ID as an arguments to my program ... and the 6th argument always end up with "-" no matter what I do ( we must use the ¿ because of a...
Pollerd asked 24/3, 2017 at 19:46

2

Solved

I am currently using a random genertor to generator numbers 9 digit numbers for me. I am currently trying to use String.format, in java, to print the random numbers like this XXX-XX-XXXX which is l...
Biocellate asked 29/1, 2017 at 23:56

4

Solved

Can I use String.Format() to pad a certain string with arbitrary characters? Console.WriteLine("->{0,18}<-", "hello"); Console.WriteLine("->{0,-18}<-", "hello"); returns -> hello...
Imagination asked 12/2, 2009 at 12:49

4

Solved

Input: uint hex = 0xdeadbeef; Required output: string result = "{deadbeef}" First approach: Explicitly add the { and }; this works: result = "{" + string.Format("{0:x}", hex) + "}"; // -> "{d...
Upspring asked 13/10, 2016 at 8:42

4

I want to use string.Format with optional parameters : public static void Main(string[] args) { // Your code goes here // Console.WriteLine(string.Format("{0} {1}", "a", "b")); Console.WriteLin...
Perjured asked 8/12, 2014 at 17:21

4

Solved

Is it possible to separate Date and time with ". So it would be: "ddMMyyyy","HHmmss" Right now i have: DateTime dt = aPacket.dtTimestamp; string d = dt.ToString("\"ddMMyyyy\",\"HHmmss\""); a...
Senzer asked 1/7, 2016 at 7:8

3

In my project (Java/Play framework) I have an error handling routing that checks the response from a web service if the response is an error code, we display the corresponding error message saying ...
Ackley asked 20/9, 2013 at 18:22

3

Solved

I am trying to get @String.Format("{0:0.00}",Model.CurrentBalance) into this @Html.TextBoxFor(model => model.CurrentBalance, new { @class = "required numeric", id = "CurrentBalance" }) I just w...
Reeve asked 5/8, 2011 at 23:4

2

I'm trying to use the str.format() function to print a matrix in columns. This is the line that goes wrong: >>>> "{!s:4}{!s:5}".format('j',4,3) 'j 4 ' >>>> "{!s:4}{!s:5}"....
Preston asked 27/4, 2015 at 6:27

2

Solved

I find a piece of code like this int a = 100; string str = $"{a:0.00}"; Console.WriteLine(str); the result is "100.00" The $ have the same function of string.Format, and I want to know which v...
Macedonia asked 28/2, 2016 at 4:48

2

Solved

I have noted that when using the framework function string.Format to format currency values, in some cultures this function rounds the decimals by default. For example, when working with Malaysian ...
Hierocracy asked 17/8, 2015 at 8:31

1

Solved

I recently upgraded from Lua 5.2.3 to 5.3.1 but I noticed all my scripts that perform a string.format started failing if it tried to format a float using %d local anExampleString = string.format("...
Aweinspiring asked 23/7, 2015 at 2:17

1

Solved

I tried to migrate a line of code that uses String.Format twice to the new .NET Framework 6 string interpolation feature but until now I was not successfull. var result = String.Format(String.Form...
Misadvise asked 14/7, 2015 at 13:31

5

Solved

I have a MVC3 HtmlHelper extension like this: public static MvcHtmlString ShowInfoBar(this HtmlHelper helper, string message, InfoMessageType messageType) { return MvcHtmlString.Create(String.Fo...
Felloe asked 17/8, 2011 at 17:50

1

Solved

Is there a format option such that >>> '%.1(format)'%2.85 gives '2.8'? In Python 2.7, 'f' format rounds to nearest >>> "{:.0f}".format(2.85) '3' >>> "%.0f"%2.85 '3' ...
Felicidad asked 26/5, 2015 at 14:10

2

Solved

I am compiling in C# using .NET 3.5 and am trying to convert a TimeSpan to a string and format the string. I would like to use myString = myTimeSpan.ToString("c"); however the TimeSpan.ToString ...
Already asked 20/7, 2012 at 12:7

12

Solved

Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new StringBuilder(); string cat = "cat"; sb.Append("the ").Append(cat).(" in the hat"); string s = sb.ToString(); would th...
Pfeffer asked 9/8, 2008 at 14:24

1

Solved

An ex-coworker wrote this: String.Format("{0:#;;} {1:records;no records;record}", rows, rows - 1); //Rows is a integer value I read articles like these Code Project - Custom String Formatting i...
Metchnikoff asked 2/9, 2014 at 16:34

1

Solved

With String.format %d and its variants, we can easily format primitive integers and longs. However, does these formatting options work perfectly with BigInteger? I've made some tests, and they see...
Aciculate asked 14/8, 2014 at 3:18

3

Solved

How do I string.format() or sprintf() in coffeescript?
Hendershot asked 26/3, 2012 at 22:6

© 2022 - 2024 — McMap. All rights reserved.