How to try parse decimal value from a string in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal d;

            if (decimal.TryParse("3.14", out d))
                Console.WriteLine(d);

            if (decimal.TryParse("c#", out d))
                Console.WriteLine(d);
        }
    }
}

/*
run:
   
3.14

*/

 



answered Jan 18, 2017 by avibootz

Related questions

1 answer 201 views
1 answer 192 views
1 answer 181 views
1 answer 194 views
1 answer 142 views
1 answer 175 views
175 views asked Jan 18, 2017 by avibootz
...