了解 FormCollection.AllKeys.Contains
我正在查看一个代码块,无法理解该行发生了什么 - formValues.AllKeys.Contains("Email_" + i);
看起来应该进行分配,但是。 ..
public ActionResult EditAdditionalLocations(int ID, int? count, FormCollection formValues)
{
...
for (int i = 0; i < _count; i++)
{
formValues.AllKeys.Contains("Email_" + i);
if (locations.Emails.Count > i)
{
locations.Emails[i] = formValues["Email_" + i];
}
else
{
locations.Emails.Add(formValues["Email_" + i]);
}
}
}
I'm looking at a code block and can't grok what's happening with the line - formValues.AllKeys.Contains("Email_" + i);
it looks like an assignment should be taking place but...
public ActionResult EditAdditionalLocations(int ID, int? count, FormCollection formValues)
{
...
for (int i = 0; i < _count; i++)
{
formValues.AllKeys.Contains("Email_" + i);
if (locations.Emails.Count > i)
{
locations.Emails[i] = formValues["Email_" + i];
}
else
{
locations.Emails.Add(formValues["Email_" + i]);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是这样的事情是有意的:
My guess is that something like this was intended:
此行检查
AllKeys
集合是否包含"Email_" + i
,但不对结果执行任何操作。This line checks whether
AllKeys
collection contains"Email_" + i
, but doesn't do anything with the result.