大佬教程收集整理的这篇文章主要介绍了C#Strange Index Out Of Bounds异常,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public messageProcessor(Outlook.MailItem theMail) { _activeMailItem = theMail; _activeMailDetails.Sender = theMail.SenderEmailAddress; if (_activeMailItem.Recipients.Count > 0) { List<String> recipients = new List<String>(); List<String> cc = new List<String>(); List<String> bcc = new List<String>(); for (int i = 0; i < _activeMailItem.Recipients.Count; i++) { switch (_activeMailItem.Recipients[i].TypE) <----- HERE { case (int)Outlook.olMailRecipientType.olTo: recipients.Add(_activeMailItem.Recipients[i].Address); break; case (int)Outlook.olMailRecipientType.olCC: cc.Add(_activeMailItem.Recipients[i].Address); break; case (int)Outlook.olMailRecipientType.olBCC: bcc.Add(_activeMailItem.Recipients[i].Address); break; } } } }
但是,我在标有“HERE”的点上得到了例外.当我调试并查看Recipients.Count属性的值时,它显示1.但是,当“i”索引为0(应该是有效索引 – 并且在这种情况下,唯一有效的索引)时会出现问题).当我尝试查看_activeMailItem.Recipients集合时,我看到Count为1;然而,当我试图在结构中进一步向下追踪时,我看到一些红色十字架,我无法检查下面的值.
有谁知道什么可能是错的?
提前致谢.
for (int i = 1; i <= _activeMailItem.Recipients.Count; i++)
以上是大佬教程为你收集整理的C#Strange Index Out Of Bounds异常全部内容,希望文章能够帮你解决C#Strange Index Out Of Bounds异常所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。