public long Convert2Long(String Str1)
        {
            try
            {
                long LngString = Int64.Parse(Str1);
                return LngString;
            }
            catch (System.FormatException)
            {
                Console.WriteLine("Parameter is not in required format");
                return -1;
            }
        }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Posts
Posts
 
 

Hi;
ReplyDeleteYour functions is only convert integer no. if i write
1.20 it return -1
or 0.02 it return -1
thanks.
Hi,
ReplyDeleteYour function can only convert integers,
i tried to convert 1.2 an 0.02, both gave me result -1.
What do you two think, what a function wich converts to Long is doing? converting floats an doubles?
ReplyDeletelong.Parse() doesn't work?
ReplyDeleteyou are just converting to ints
ReplyDeleteInt64 is a 64-bit Integer or Long. If you want to convert a double, you need to use Double.Parse().
ReplyDeleteNice conversion tips.
ReplyDelete