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

Crni Gorac cgorac@webmail.co.yu
Fri, 5 Apr 2002 13:16:43 -0800 (PST)


--- John Barnette <jbarn@httcb.net> wrote:
>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.
>


John,

Thank you very much - that was exactly the piece I was missing. And it's
actually surprisingly similar to Perl :) But please note that it wasn't my
intention to ban C# - it is too early for me to make judgments on language. I
only felt once again an impression that while new languages are making complex
tasks easy, they are also sometimes making ubiquitous tasks cumbersome
(e.g. C++ overloaded << operators on streams are certainly much more elegant
than above).

Regards,
Crni


_____________________________________________________________
Besplatan email za SVE - ime@webmail.co.yu - http://www.webmail.co.yu

_____________________________________________________________
Run a small business? Then you need professional email like you@yourbiz.com from Everyone.net  http://www.everyone.net?tag