🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: FindIntegerinStr

#355
From: Sean
Date: Mon, 14 Feb 2005 19:59
44 lines
1930 bytes
Hi Jeff

Use apCode.IndexOfAny();

Check the help for the syntax.

Cheers Sean

Jeff wrote:
> I am passing a sting to a function and trying to locate the position of 
> the first digit in the string, if there is one.  In Delphi I had the 
> following:
> 
> function FrmLoad.LocateDigit(aPCode: string): Integer;
> begin
>   for result := 1 to Length(aPCode) do
>     begin
>       if aPCode[result] in ['0'..'9'] then
>          Exit;
>      end;
> 
>   result := 0;
> end;
> 
> Here is what I have in C#:
> 
> private int LocateDigit(string aPCode)
> {
> 
>   int result = 0;
> 
> for(int i = 0; i<aPCode.Length; i++)
> {
>     if (aPCode(result) in ["0".."9"]) ---This line errors
>        exit;
> }
> 
> return int(result);
> }
> 
> How would I accomplish the same in C#?
> 
> TIA
> 
Technical Details
Message-ID: <42110318$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4210c68f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,66c7f96838fd6e37
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 15 Feb 2005 08:59:19 +1300
From: Sean <sathomas@SPAMiconz.co.nz>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.csharpbuilder.language.csharp
Subject: Re: FindIntegerinStr
References: <4210c68f$1@newsgroups.borland.com>
In-Reply-To: <4210c68f$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 210.48.81.60
Message-ID: <42110318$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1108411160 210.48.81.60 (14 Feb 2005 11:59:20 -0800)
Lines: 44
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail