I need to format my number like 123456 to 1,23,456 1234567 to 12,34,567 12345678 to 1,23,45,678 123456789 to 12,34,56,789
Asked
Active
Viewed 396 times
1
-
no sir, basically all of format show only 3 digit separate comma, but I need 3 and 2 both digit comma – GH Palash Jun 13 '21 at 11:04
-
Take a look at this thread, i believe this will help. [number format](https://stackoverflow.com/questions/4954777/format-number-in-c-sharp) – cbrr09 Jun 13 '21 at 11:04
-
Does this answer your question? [format number in C#](https://stackoverflow.com/questions/4954777/format-number-in-c-sharp) – reduckted Jun 13 '21 at 11:13
1 Answers
4
I believe you are looking for conversion to Indian counting format.
Use the below code to format the string
string.Format(new System.Globalization.CultureInfo("hi-IN"), "{0:#,#}", number)
Using the above code the output of inputted number would be
string.Format(new System.Globalization.CultureInfo("hi-IN"), "{0:#,#}", 123456)
string.Format(new System.Globalization.CultureInfo("hi-IN"), "{0:#,#}", 1234567)
string.Format(new System.Globalization.CultureInfo("hi-IN"), "{0:#,#}", 12345678)
1,23,456
12,34,567
1,23,45,678
Check this dotnet fiddle - https://dotnetfiddle.net/TXQ09n

user1672994
- 10,509
- 1
- 19
- 32