How to convert string with numbers and comma to integer (int) number in C#

1 Answer

0 votes
using System;
using System.Globalization;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "12,345";

            int i = int.Parse(s, NumberStyles.AllowThousands);
            Console.WriteLine(i); // 12345

            i++;
            Console.WriteLine(i); // 12346
        }
    }
}

/*
run:
 
12345
12346

*/


answered Feb 15, 2015 by avibootz

Related questions

1 answer 184 views
1 answer 267 views
1 answer 146 views
1 answer 166 views
...