开发者

How to find an object from a List of objects?

I got a list of columns in the variable ParentColumnNames, i need to find a single Column object within this list using the selectedvalue of another combobox. How can i get that? Please help...

List&开发者_JAVA技巧lt;Columns> ParentColumnNames = new List<Columns>();
     ParentColumnNames = metadataobj.GetColumns(cbParentTable.SelectedItem.ToString());

within this i need to find single object using cbParentColumn.SelectedValue.


Try something like this:

ParentColumnNames.Where(x => x.Name == cbParentColumn.SelectedValue).FirstOrDefault();

My answer assumes that the Columns class has a property Name and that this property contains the value you are looking for.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜