How can I convert values in euro currency?


How i can convert values in euro currency

For Example:- if There is 25000 then output will be €25.000

If There is 995 then €9,95


Asked by:- RahulMungra
0
: 1970 At:- 2/18/2021 11:28:06 AM
C# Currency format







1 Answers
profileImage Answered by:- vikas_jk

You can use built in .NET currency formatting, or you can customise it using code logic, here is the example of both

           var dec = 25000;
           string total = dec.ToString("C", new CultureInfo("en-GB")); // £25,000.00


           Console.WriteLine(total);
            
           
            var val = 995;
             //custom check if number is three digit number
            //add comma after first one.
            if(val < 1000 && val > 99)
            {
                var val2 = "£" + val.ToString().Substring(0, 1) + "," + val.ToString().Substring(1, 2);
                Console.WriteLine(val2); // output: £9,95

            }

In the above code for "995", I have implemented my own logic to manipulate value.

0
At:- 2/23/2021 3:51:33 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use