c# - Storing complex data in a list -
i'm working product called sitefinity.
i have class looks so:
public class categories {         public icontent ocontent {get; set;}     }   i'm looping through list , trying check whether current value exists, so:
ilist items = base.createdatasource(); ilist filteredlist = new list<string>();  foreach (icontent cnt in items) {    if (!filteredlist.contains(cnt))     {         filteredlist.add(cnt);     } } return filteredlist;   but returns error. using .contains correctly?
update:
ok have updated:
list<icontent> filteredlist = new list<icontent>();   however, icontent has method can called extract further information, so:
foreach(icontent cnt in items) {     string strcat = cnt.getmetadata("category"); }   now although want filteredlist contain multiple icontent items, want check against string getmetadata before deciding whether item should added. make sense?
thanks.
you cannot add icontent object list<string>, since list<string> can hold strings.
change list<icontent> , work fine.
also, c#is not java; not declare list variables ilist.
 had declared them actual types (list<string> , whatever createdatasource returns), wouldn't have had issue.
Comments
Post a Comment