开发者

how to remove one entity in list and add the another entity in same list in c# [closed]

开发者 https://www.devze.com 2022-12-14 21:37 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answe开发者_如何学运维red in its current for
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answe开发者_如何学运维red in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消