January 28th, 2016

KISSCode money stringvalue

by Adhi.Lius

Hi fellas, okay for today it is going to be a short one.

A simple trick that I got stuck but actually an easier solution is out there > o <

Let us say you want to put a numerical text for money string:$ 1.000.000,00 or $ 1,000,000.00.

Okay I used to need like do lots of stuff, substring, read the length, dividing and etc etc.


But actually in C# there is actually a simple trick to it.

The trick is: You can actually send a value to .ToString function in basic int, double, float

So you can easily use:

int value = 1000000;

debug.log("display $"+value.toString("C"));

//result will display $1,000,000.00

Look at that, so short.

Anyway, it seems there are more specifiers you can use for more type of numerical value. You can check it from here if you want

And that is for today. Hurray and as usual.

Hope you like #KISSCodeThursday

Originally from blog.sinergistudio.com

Comments (0)