Re: Code optimization...

Discussion in 'ASP .Net' started by Pete Wright, Jul 5, 2003.

  1. Pete Wright

    Pete Wright Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    >
    Pete Wright, Jul 5, 2003
    #1
    1. Advertising

  2. Thanks very much for your reply, Peter...

    Sincerely,

    Raphaël Désalbres


    "Pete Wright" <> escreveu na mensagem
    news:be70io$8t1$1$...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >

    >
    >
    Raphaël Désalbres, Jul 5, 2003
    #2
    1. Advertising

  3. Pete Wright

    David Waz... Guest

    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" <> wrote in message
    news:be70io$8t1$1$...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >

    >
    >
    David Waz..., Jul 6, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Russell Wallace
    Replies:
    7
    Views:
    402
    Russell Wallace
    Jun 11, 2004
  2. ashu

    optimization of vhdl code

    ashu, May 8, 2006, in forum: VHDL
    Replies:
    5
    Views:
    4,026
  3. ashu
    Replies:
    5
    Views:
    1,192
    umerarain
    May 16, 2006
  4. joshc
    Replies:
    14
    Views:
    781
    Keith Thompson
    Jan 14, 2005
  5. Ravikiran

    Zero Optimization and Sign Optimization???

    Ravikiran, Nov 17, 2008, in forum: C Programming
    Replies:
    22
    Views:
    858
    Thad Smith
    Nov 24, 2008
Loading...

Share This Page