简体   繁体   中英

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 ?

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>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM