Click here to Skip to main content
15,566,522 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
When I add an item from .aspx.cs page, I got three ways to do it as following

ddlCalanderName.Items.Insert(0, new ListItem("Item1" , "0"));
ddlCalanderName.Items.Insert(0, new ListItem("Item1"));
ddlCalanderName.Items.Insert(0, "Item1");


It gives me same output

Can any one tell me what is the diffrence betwween these three?

Thanks
Posted
Updated 11-Aug-11 2:23am
v2

1 solution

It's called method overloading, and you're using both of the overloads for the Insert method.

The only one that does something different is the first one. It sets the text (the way it appears visually to the user in the list) and the value of the item (two different things), where the other two just set the text.
 
Share this answer
 
v2
Comments
Christoph Keller 11-Aug-11 15:18pm    
Just correct, my 5+ :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900