Αποτελέσματα Αναζήτησης
9 Σεπ 2010 · You can do the entire conversion in one line, using the following code: String number = "1000500000.574"; String convertedString = new DecimalFormat("#,###.##").format(Double.parseDouble(number)); The last two # signs in the DecimalFormat constructor can also be 0s. Either way works.
12 Οκτ 2015 · The 10 cent answer to this is: C#'s. String.Format("{0} -- {1} -- {2}", ob1, ob2, ob3) is equivalent to Java's. String.format("%1$s -- %2$s -- %3$s", ob1, ob2, ob3) Note the 1-based index, and the "s" means to convert to string using .toString ().
19 Νοε 2021 · Custom numeric format strings are supported by some overloads of the ToString method of all numeric types. For example, you can supply a numeric format string to the ToString (String) and ToString (String, IFormatProvider) methods of the Int32 type.
Converts the value of objects to strings based on the formats specified and inserts them into another string. If you are new to the String.Format method, see Get started with the String.Format method for a quick overview.
The Format() method returns a formatted string based on the argument passed. In this tutorial, we will learn about the C# String.Format() method with the help of examples.
15 Μαΐ 2012 · You can use Int32.ToString("000") to format an integer in this manner. For details, see Custom Numeric Format Strings and Int32.ToString: string one = a.ToString("000"); // 001 string two = b.ToString("000"); // 010
17 Φεβ 2010 · There’s two ways to produce a number, composite or plain formatted string in C#. The first is used by Console.WriteLine, string.Format,StringBuilder.AppendFormat, TextWriter.WriteLine and comes in the format: Console.WriteLine("{0} {1} {2}",100,200,3000); Output: 100 200 3000.