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

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "893";

            short s;
            if (short.TryParse(str, out s))
                Console.WriteLine(s);

            str = "99999999";

            if (short.TryParse(str, out s))
                Console.WriteLine(s);
        }
    }
}

/*
run:
   
893

*/

 



answered Jan 17, 2017 by avibootz

Related questions

1 answer 211 views
1 answer 177 views
1 answer 202 views
1 answer 189 views
1 answer 205 views
205 views asked Jan 17, 2017 by avibootz
1 answer 182 views
182 views asked Jan 18, 2017 by avibootz
...