how to remove one entity in list and add the another entity in same list in c# [closed]
how to remove one entity in list and add the another entity in same list in c#
var yourList = new Collection<EntityType>();
yourList.Remove( entity );
yourList.Add( otherEntity );
or replace by:
yourList[yourList.IndexOf( entity )] = otherEntity;
Suppose you have a ListBox named listBox1. If you want to remove the selected item from it, use the Items.Remove() method, and pass as an argument the SelectedItem property. Same for add entity Items.Add() and pass as an value you want to insert.
精彩评论