开发者

Parts of BindingList to string array

I'm am using the BindingList to populate some controls.

On part of a form I need to use some of the data stored within the BindingList to create and array. Say I have BindingList<CEmployee> and wanted to retrieve all CEmployee.Surnames into a string array how would I go about this without looping through each CEmployee in the BindingList?

开发者_JAVA百科Regards

Taff


You can use LINQ to query the Surnames:

var surnames = from employee in myBindingList select employee.Surname;

If you need it as an Array, you can use the ToArray method of the result:

string[] surnamesArray = surnames.ToArray<string>();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜