I have a string like price:  string price= "5000000";   but i want to know, how can i change it (in c#) to something like this:  "5,000,000"   because it's very better and user friendly.
20276
I want to add a comma in the thousands place for a number.     String.Format()?
119341
I'm pretty new to programming and made a few programs so far. I recently made a Calculator program and I hope you guys could tell me what I could do to improve. int firstNumber; string sign; int secondNumber; int answer;  Console.WriteLine(&quot;Input Number:&quot;); firstNumber = Convert.ToInt32(Console.ReadLine()); Console.Clear();  Console.WriteLine(&quot;Input Sign:&quot;); sign = Console.ReadLine(); Console.Clear();  Console.WriteLine(&quot;Input Second Number:&quot;); secondNumber = Convert.ToInt32(Console.ReadLine()); Console.Clear();  switch (sign) {     case &quot;+&quot;:         answer = firstNumber + secondNumber;         Console.WriteLine(answer);         Console.ReadKey();     break;     case &quot;-&quot;:         answer = firstNumber - secondNumber;         Console.WriteLine(answer);         Console.ReadKey();     break;     case &quot;*&quot;:         answer = firstNumber * secondNumber;         Console.WriteLine(answer);         Console.ReadKey();     break;     case &quot;/&quot;:         answer = firstNumber / secondNumber;         Console.WriteLine(answer);         Console.ReadKey();     break;     default:         Console.WriteLine(&quot;Invalid Input&quot;);     break; }
101805
I am not familiar with PHP at all and had a quick question.  I have 2 variables pricePerUnit and InvoicedUnits. Here's the code that is setting these to values:  $InvoicedUnits = ((string) $InvoiceLineItem-&gt;InvoicedUnits); $pricePerUnit = ((string) $InvoiceLineItem-&gt;PricePerUnit);   If I output this, I get the correct values. Lets say 5000 invoiced units and 1.00 for price.  Now, I need to show the total amount spent. When I multiply these two together it doesn't work (as expected, these are strings).  But I have no clue how to parse/cast/convert variables in PHP.  What should I do?
30638
I'm struggling to use String.format to replace a token with a value when the token is within single quotes:  Example:  String query = String.format('SELECT Id FROM Availability WHERE Person__c = \'{0}\'', personId);   String query is equal to:  SELECT Id FROM Availability WHERE Person__c = {0}   Rather than:  SELECT Id FROM Availability WHERE Person__c = '234567890'
2140
What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations.  I also would like only significant digits to be displayed - i.e. there should not be any trailing zeroes.  I know one method of doing this is to use the String.format method:  String.format("%.5g%n", 0.912385);   returns:  0.91239   which is great, however it always displays numbers with 5 decimal places even if they are not significant:   String.format("%.5g%n", 0.912300);   returns:  0.91230   Another method is to use the DecimalFormatter:  DecimalFormat df = new DecimalFormat("#.#####"); df.format(0.912385);   returns:  0.91238   However as you can see this uses half-even rounding. That is it will round down if the previous digit is even. What I'd like is this:  0.912385 -&gt; 0.91239 0.912300 -&gt; 0.9123   What is the best way to achieve this in Java?
53171
Formatting numbers on a VF page, but I do a bunch of processing the Apex Class, so I would rather return the formatted String value from the controller.   I am doing something like this, but I just want the second number to appear as "(1500)" rather "-1500"  Getting lost in the Message Format docs, so hoping someone can guide me in the right direction...  List&lt;String&gt; args = new String[]{'0','number','###,###,###'}; system.debug('Positive' + String.format(  ( (1000) - (500.50)  ).round().format(), args) ); system.debug('Negative' + String.format(  ( (-1000) - (500.50)  ).round().format(), args) );
99569
Is there a way to write binary literals in C#, like prefixing hexadecimal with 0x? 0b doesn't work.  If not, what is an easy way to do it? Some kind of string conversion?
32163
Is there an easy way in C# to create  for a number? For example:   1 returns 1st 2 returns 2nd 3 returns 3rd ...etc   Can this be done through String.Format() or are there any functions available to do this?
275
Which is the preferred way to convert an Enum to a String in .NET 3.5?   Enum.GetName Enum.Format ToString   Why should I prefer one of these over the others? Does one perform better?
115101
I am getting one value from webservice as a string (KM value , say 500000) . I want to display that in an inline vf page as 50,000. How to achieve this in apex controller. I am displaying the valu in a apex datatable as column value.  Please help me out  Eg ; 50000 should be 50,0000 OR 5000000 should be 5,000,000
23076
How do I go from this string: "ThisIsMyCapsDelimitedString"  ...to this string: "This Is My Caps Delimited String"  Fewest lines of code in VB.net is preferred but C# is also welcome.  Cheers!
32361
I have some numbers of different length (like 1, 999, 76492, so on) and I want to convert them all to strings with a common length (for example, if the length is 6, then those strings will be: '000001', '000999', '076492').   In other words, I need to add correct amount of leading zeros to the number.  int n = 999; string str = some_function(n,6); //str = '000999'   Is there a function like this in C++?
71900
In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time.  In said languages, there are library classes to reduce this cost such as C# System.Text.StringBuilder and Java java.lang.StringBuilder.  Does php (4 or 5; I'm interested in both) share this limitation?  If so, are there similar solutions to the problem available?
19898
Is there an efficient method of converting an integer into the written numbers, for example:  string Written = IntegerToWritten(21);   would return "Twenty One".  Is there any way of doing this that doesn't involve a massive look-up table?
25338
I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount% with a value pulled from a database. The problem is the capitalization of FirstName varies. That prevents me from using the String.Replace() method. I've seen web pages on the subject that suggest  Regex.Replace(strInput, strToken, strReplaceWith, RegexOptions.IgnoreCase);   However for some reason when I try and replace %PolicyAmount% with $0, the replacement never takes place. I assume that it has something to do with the dollar sign being a reserved character in regex.   Is there another method I can use that doesn't involve sanitizing the input to deal with regex special characters?
78703
If have this in the setter of a property:  decimal? temp = value as decimal?;   value = "90"  But after the cast, temp is null...  What is the proper way to do this cast?
27421
In C#, I want to initialize a string value with an empty string.  How should I do this?  What is the right way, and why?  string willi = string.Empty;   or  string willi = String.Empty;   or  string willi = "";   or what?