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

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -