🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #674

Re: Where are StrToXXXDef and TryStrToXXX?

#674
From: Eric
Date: Tue, 19 Oct 2004 14:38
31 lines
1406 bytes
Theo Bebekis wrote:

> Hi
> 
> Is there any equivalent to Delphi's
>    StrToXXXDef and
>    TryStrToXXX

Use the Parse method of the desired target class, or use the Convert
class.

myInt = Int32.parse(myStr);
or
myInt = Convert.toInt32(myStr);

You need to handle exceptions in case these fail:

try 
{
   myInt = Convert.toInt32(myStr);
}
catch(Exception)
{
   Console.WriteLine("error converting to int");
}

There's a TryParse method on the double type, and in v2.0 of the
Framework it will be added to all the types. This is good because it
avoids throwing an exception if the conversion fails.

Eric
Technical Details
Message-ID: <417526d7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4174fd87@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,11f13a69b08b4c7a
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Eric" <Eric>
Subject: Re: Where are StrToXXXDef and TryStrToXXX?
Newsgroups: borland.public.csharpbuilder.language.csharp
References:  <4174fd87@newsgroups.borland.com>
User-Agent: XanaNews/1.16.4.2
NNTP-Posting-Host: 216.206.90.2
Message-ID: <417526d7@newsgroups.borland.com>
Date: 19 Oct 2004 07:38:15 -0700
X-Trace: newsgroups.borland.com 1098196695 216.206.90.2 (19 Oct 2004 07:38:15 -0700)
Lines: 31
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail