Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert dot symbol into a string number

Tags:

c#

.net

I have int variables, example:

int money = 1234567890;

How I can insert "." into money, and make its format like this:

1.234.567.890
like image 362
furyfish Avatar asked Nov 26 '12 03:11

furyfish


People also ask

How do you put a dot in a string?

Insert(0,"."); Where 0 is the starting Index (Where you want to put the dot). And "." is what you want to put.

How do you add a dot in Python?

Write a function named add_dots that takes a string and adds "." in between each letter. For example, calling add_dots("test") should return the string "t.e.s.t" . Then, below the add_dots function, write another function named remove_dots that removes all dots from a string.


1 Answers

You can simply do this:

var text = money.ToString("N0",
    System.Globalization.CultureInfo.GetCultureInfo("de"));

The result is:

1.234.567.890

(I just picked the German culture as I knew they use . for the separator.)

like image 185
Enigmativity Avatar answered Oct 03 '22 21:10

Enigmativity