c# - List is changed when I update another list with same data type -
my code looks this.
public class category { public string catid { get; set; } public string catname { get; set; } public string specid { get; set; } pubic string specname { get; set; } } list<category> lstcategory = new list<category>(); list<category> lstcatwithspec = new list<category>(); now, want add category first in lstcatwithspec. copy list in lstcategory , add specialties in lstcatwithspec. now, when update list specialties, list in copied categories changed. filled specialties. should not change right ?
how possible when have 2 different objects , give specific object name when adding items ?
as working on xamarin.forms, have tagged xamarin.forms because don't know if exists in c# or not.
edit -
i tried add list using foreach loop.
foreach( var item in lstcatwithspec) { lstcategory.add(item); } and tried also.
lstcategory = new list<category>(lstcatwithspec); thank you.
Comments
Post a Comment