it's all about semantics

Discussion in 'ASP .Net' started by =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=, Jul 13, 2004.

  1. Hi
    Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:

    ---

    ListItem[] litems = new ListItem[5];
    for (int i = 0; i < 5; i++)
    litems = new ListItem("text"+i,"value"+i);

    DropDownList ddl;
    for (int j = 0; j < 3; j++)
    {
    ddl = new DropDownList();
    ddl.Items.AddRange(litems);
    //assume PlaceHolder1 exists on WebForm
    PlaceHolder1.Controls.Add(ddl);
    }
    //Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
    ((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;

    ---

    So, what do you think is the outcome of the above code?
    What do you think of the code/effect semantics in this case?

    dimitris
     
    =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=, Jul 13, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=

    Scott G. Guest

    I'll answer with a quiz: Do you think that "sharing" ListItems in multiple DropDownLists would do something different than set the SelectedItem for all three DropDownLists?

    Scott
    "Dimitris Pantazopoulos" <> wrote in message news:...
    Hi
    Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:

    ---

    ListItem[] litems = new ListItem[5];
    for (int i = 0; i < 5; i++)
    litems = new ListItem("text"+i,"value"+i);

    DropDownList ddl;
    for (int j = 0; j < 3; j++)
    {
    ddl = new DropDownList();
    ddl.Items.AddRange(litems);
    //assume PlaceHolder1 exists on WebForm
    PlaceHolder1.Controls.Add(ddl);
    }
    //Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
    ((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;

    ---

    So, what do you think is the outcome of the above code?
    What do you think of the code/effect semantics in this case?

    dimitris
     
    Scott G., Jul 13, 2004
    #2
    1. Advertising

  3. I think it is not a logical "sharing" practice in this case.

    whoever engineered that was loco.

    dimitris


    "Scott G." wrote:

    > I'll answer with a quiz: Do you think that "sharing" ListItems in multiple DropDownLists would do something different than set the SelectedItem for all three DropDownLists?
    >
    > Scott
    > "Dimitris Pantazopoulos" <> wrote in message news:...
    > Hi
    > Instead of a direct opinion on the following matter I prefer to post it as a quiz. What do you expect the code below does:
    >
    > ---
    >
    > ListItem[] litems = new ListItem[5];
    > for (int i = 0; i < 5; i++)
    > litems = new ListItem("text"+i,"value"+i);
    >
    > DropDownList ddl;
    > for (int j = 0; j < 3; j++)
    > {
    > ddl = new DropDownList();
    > ddl.Items.AddRange(litems);
    > //assume PlaceHolder1 exists on WebForm
    > PlaceHolder1.Controls.Add(ddl);
    > }
    > //Now the tricky part - set selectedIndex for 2nd dropdownlist control, let's say:
    > ((DropDownList)PlaceHolder1.Controls[1]).SelectedIndex = 0;
    >
    > ---
    >
    > So, what do you think is the outcome of the above code?
    > What do you think of the code/effect semantics in this case?
    >
    > dimitris
     
    =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=, Jul 14, 2004
    #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. Luigi Donatello Asero

    Semantics extractor

    Luigi Donatello Asero, Feb 14, 2004, in forum: HTML
    Replies:
    5
    Views:
    562
    Eric Bohlman
    Feb 14, 2004
  2. Alexander Stippler

    destructor / semantics of delete this

    Alexander Stippler, Aug 20, 2003, in forum: C++
    Replies:
    6
    Views:
    2,207
    Chris Theis
    Aug 20, 2003
  3. Stefan Höhne

    std::vector<>::clear semantics

    Stefan Höhne, Oct 16, 2003, in forum: C++
    Replies:
    10
    Views:
    2,964
    tom_usenet
    Oct 17, 2003
  4. Grant Austin
    Replies:
    3
    Views:
    459
    Peter van Merkerk
    Dec 9, 2003
  5. David Rasmussen
    Replies:
    4
    Views:
    430
    David Rasmussen
    Jan 12, 2004
Loading...

Share This Page