LKB*_*LKB 3 c# string list add
有没有比下面的示例更快或更有效的方法将字符串添加到列表?:
List<String> apptList = new List<String>();
foreach (Appointment appointment in appointments){
String subject = appointment.Subject;
//...(continues for another 10 lines)
//...And then manually adding each String to the List:
apptList.Add(subject);
//...(continues for another 10 lines)
//And then send off List apptList to another method
}
Run Code Online (Sandbox Code Playgroud)
var apptList = appointments.Select(a => a.Subject).ToList();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
131 次 |
| 最近记录: |