开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜