Article View: alt.pl.comp.lang.csharp
Article #244Re: Czegos chyba nie kapuje :(
From: Daniel Dusiñski www.dusinski.prv...
Date: Thu, 27 Nov 2003 22:36
Date: Thu, 27 Nov 2003 22:36
25 lines
1740 bytes
1740 bytes
> int i=0
> int x=0;
> string tekst= "tralalalalalalalalalalalala";
> while (tekst[x].ToString() != null)
> {
> i++;
> x++;
> }
>
> Co jest nie tak? Ma on liczyc znaki... Ale zawiesza sie.
Dok�adniej wywala wyj�tek System.IndexOutOfRangeException (przekroczenie
zakresu).
Po prostu dla x > tekst.Length (a to w ko�cu w Twoim programie zachodzi...) masz
rzucany wyj�tek. Program ko�czy swoje dzia�anie.
Jeszcze raz: dla string tekst = "aa"; poprawne b�dzie odwo�anie
tekst[1], ale na pewno nie b�dzie poprawne odwo�anie tekst[100] czy te�
tekst[2] !!!
PS. A nie mo�esz po prostu u�y� tekst.Length ???
--
Pozdrawiam, | www.dusinski.prv.pl gg 4563846
Daniel | Aby wys�a� do mnie maila wejd� na stron� www
Technical Details
Message-ID:
<bq5ua7$9pf$1@news.atman.pl>Path:
mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!news.atman.pl!not-for-mailReferences:
<bq5tah$nou$1@inews.gazeta.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!news.atman.pl!not-for-mail From: Daniel Dusiñski, www.dusinski.prv.pl <WejdzN...@dusinski.prv.pl> Newsgroups: alt.pl.comp.lang.csharp Subject: Re: Czegos chyba nie kapuje :( Date: Thu, 27 Nov 2003 23:36:53 +0100 Organization: ATMAN Lines: 27 Message-ID: <bq5ua7$9pf$1@news.atman.pl> References: <bq5tah$nou$1@inews.gazeta.pl> NNTP-Posting-Host: staticline634.toya.net.pl X-Trace: news.atman.pl 1069972616 10031 217.113.228.59 (27 Nov 2003 22:36:56 GMT) X-Complaints-To: use...@atman.pl NNTP-Posting-Date: Thu, 27 Nov 2003 22:36:56 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit