【发布时间】:2018-05-17 03:17:30
【问题描述】:
目前我正在使用 Outlook,并且正在遍历项目列表。
这里的问题: 我想在 foreach 循环中询问当前项是否是最后一项 - 但我无法完成此类问题。
这是我的代码:
lastAppointmentItem = myAppointmentItems.GetLast();
foreach (Outlook.AppointmentItem myItem in myAppointmentItems)
{
// Types
// myAppointmentItems = Outlook.Items
// myItem = Outlook.AppointmentItem
if(myItem.Equals(lastAppointmentItem)) { do_something(); }
}
当我运行程序时,我得到一个
System.Runtime.InteropServices.COMException:
// The last element of the list cannot be called
那么我该如何解决我的问题 - 你们知道吗?
提前致谢!
您好。
【问题讨论】:
标签: c# .net list collections outlook