[Mono-list] problem with Console and mono-0.10

John Barnette jbarn@httcb.net
Fri, 05 Apr 2002 13:35:09 -0700


At 01:11 PM 4/5/2002, Crni Gorac wrote:
>Another question (shameless because I know this is not right place to ask 
>it, but still): how to parse numbers from an input line in C#? I need to 
>parse three double numbers that are in same input line, like this:
>   0.21 0.43 0.65

Crni,

Given:

         string args = "0.21 0.43 0.65";

Try:

         foreach (string arg in args.Split(new char[] { ' ' }))
         {
                 try
                 {
                         double argValue = double.Parse(arg);
                 }
                 catch
                 {
                         // double.Parse() may throw:
                         // ArgumentNullException
                         // FormatException
                         // OverflowException
                 }
         }

Many of the differences you're seeing with respect to Perl are a product of 
the basic divorce of strongly- and weakly-typed languages.

Hope this helps,


~ j.