How to update a List in C# -


ilist<receiptallocationmaster> objreceiptmaster = (ilist<receiptallocationmaster>)session["allocationresult"];  public class receiptallocationmaster {     public string application { get; set; }      public list<users> users { get; set; } }  public class users {     public string name { get; set; }      public string surname { get; set; } } 

i need update above list value application = "applicationame" , users surname = "surname" same list.

just iterate on list , modify matched items:

        (int = 0; < objreceiptmaster.count; i++)         {             var item = objreceiptmaster[i];             if (item.application == "applicationname" && item.users.any(x => x.surname == "surname"))                 objreceiptmaster[i] = new receiptallocationmaster();         } 

instead of new receiptallocationmaster() can write modification data logic.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -