Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Code optimization...

Reply
Thread Tools

Re: Code optimization...

 
 
Pete Wright
Guest
Posts: n/a
 
      07-05-2003
This is a trick question right? I mean, you know that there is only one
element in the rsc.SelectedIndexes, so how would you optimize the loop.

Ok, well, on the off-chance that it's not a trick question (and, BTW, Index
= selectedIndex.ToString will never work, since Index is an integer and
ToString() returns a string, but anyway....

Dim Index as Integer
Index = Int32.Parse(rsc.SelectedIndexes(1))

There yah go - I am of course assuming that the index of the one item in the
array is item number 1.
--
Peter Wright
Author of ADO.NET Novice To Pro, from Apress Inc.


"Raphaël Désalbres" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I would like to optimize the following code, knowing that there is only

one
> element in SelectedIndexes.
>
> Dim selectedIndex, Index As Integer
> For Each selectedIndex In rsc.SelectedIndexes
> Index = selectedIndex.ToString
> Next
>
> Thanks,
>
> Raphaël Désalbres
>
>
>



 
Reply With Quote
 
 
 
 
Raphaël Désalbres
Guest
Posts: n/a
 
      07-05-2003
Thanks very much for your reply, Peter...

Sincerely,

Raphaël Désalbres


"Pete Wright" <(E-Mail Removed)> escreveu na mensagem
news:be70io$8t1$1$(E-Mail Removed)...
> This is a trick question right? I mean, you know that there is only one
> element in the rsc.SelectedIndexes, so how would you optimize the loop.
>
> Ok, well, on the off-chance that it's not a trick question (and, BTW,

Index
> = selectedIndex.ToString will never work, since Index is an integer and
> ToString() returns a string, but anyway....
>
> Dim Index as Integer
> Index = Int32.Parse(rsc.SelectedIndexes(1))
>
> There yah go - I am of course assuming that the index of the one item in

the
> array is item number 1.
> --
> Peter Wright
> Author of ADO.NET Novice To Pro, from Apress Inc.
>
>
> "Raphaël Désalbres" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > I would like to optimize the following code, knowing that there is only

> one
> > element in SelectedIndexes.
> >
> > Dim selectedIndex, Index As Integer
> > For Each selectedIndex In rsc.SelectedIndexes
> > Index = selectedIndex.ToString
> > Next
> >
> > Thanks,
> >
> > Raphaël Désalbres
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
 
David Waz...
Guest
Posts: n/a
 
      07-06-2003
but, only two problems here

first, that's why there's a .ToString method - to convert the integer to
string, so that will work.

and secondly, the index, i believe, is ZERO based:
rcs.SelectedIndexes(0)

and finally, what ASPX control has a SelectedIndexes collection in the first
place? I don't recall any.
There are 3rd party controls that use this, but ASPX???


Pete, I think this WAS a trick question!


"Pete Wright" <(E-Mail Removed)> wrote in message
news:be70io$8t1$1$(E-Mail Removed)...
> This is a trick question right? I mean, you know that there is only one
> element in the rsc.SelectedIndexes, so how would you optimize the loop.
>
> Ok, well, on the off-chance that it's not a trick question (and, BTW,

Index
> = selectedIndex.ToString will never work, since Index is an integer and
> ToString() returns a string, but anyway....
>
> Dim Index as Integer
> Index = Int32.Parse(rsc.SelectedIndexes(1))
>
> There yah go - I am of course assuming that the index of the one item in

the
> array is item number 1.
> --
> Peter Wright
> Author of ADO.NET Novice To Pro, from Apress Inc.
>
>
> "Raphaël Désalbres" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > I would like to optimize the following code, knowing that there is only

> one
> > element in SelectedIndexes.
> >
> > Dim selectedIndex, Index As Integer
> > For Each selectedIndex In rsc.SelectedIndexes
> > Index = selectedIndex.ToString
> > Next
> >
> > Thanks,
> >
> > Raphaël Désalbres
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the difference between code inside a <script> tag and code in the code-behind file? keithb ASP .Net 1 03-29-2006 01:00 AM
Fire Code behind code AND Javascript code associated to a Button Click Event =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?= ASP .Net 4 02-11-2004 07:31 AM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM
Re: C# Equivalent of VB.Net Code -- One line of code, simple Ian ASP .Net 0 06-25-2003 01:14 PM
Re: C# Equivalent of VB.Net Code -- One line of code, simple Ron ASP .Net 1 06-24-2003 07:18 PM



Advertisments