Click here to Skip to main content
11,428,876 members (63,609 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET LINQ
public class itemslist
        {
            public string item1 { get; set; }
            public string item2 { get; set; }
            public string item3 { get; set; }
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
                    
         List<itemslist> obLstjitemslist=new List<itemslist>();
         itemslist objitemslist=new itemslist();
            objitemslist.item1="item1";
            objitemslist.item2="item2";
            objitemslist.item3="item3";
       obLstjitemslist.Add(objitemslist);
             objitemslist.item1="item11";
            objitemslist.item2="item12";
            objitemslist.item3="item13";
       obLstjitemslist.Add(objitemslist);

In the above example how to remove item2 in List?
Posted 12-Feb-13 19:28pm
Edited 12-Feb-13 20:01pm
v4

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The question makes no sense, because "item2", or the value of the member item2 is not "added" to anything. The type itemlist is not a list, so it does not have such concept as "remove".

However, obLstjitemslist is a list, but the list of the elements of the type itemlist. When the code is executed, it has two items, but none of those items is "item2". So, again, nothing to remove.

—SA
  Permalink  
Comments
Sandeepkumar potu at 13-Feb-13 0:49am
   
i just want to remove objitemslist.item2 in List
Sergey Alexandrovich Kryukov at 13-Feb-13 0:51am
   
I already answered. What cannot you get?
—SA
Sandeepkumar potu at 13-Feb-13 1:14am
   
ok can i skip objitemslist.item2 while adding to List
Sergey Alexandrovich Kryukov at 13-Feb-13 1:20am
   
You cannot skip, add or delete it. This is not an item.
—SA

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



Advertise | Privacy | Mobile
Web01 | 2.8.150428.2 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100