C# 检查mvc formcollection中是否存在元素

C# 检查mvc formcollection中是否存在元素,c#,asp.net-mvc,formcollection,C#,Asp.net Mvc,Formcollection,我在mvc控制器中接收一些数据作为FormCollection。我想检查formcollection中是否存在特定的密钥 public JsonResult FullRetailerUpdate(FormCollection data) { //I want to check if //data["AnElement"] is exist } 请提供帮助。尝试使用.Contains():- 我知道问题是关于FormCollection的,但是对于那些使用FormCo

我在mvc控制器中接收一些数据作为FormCollection。我想检查formcollection中是否存在特定的密钥

 public JsonResult FullRetailerUpdate(FormCollection data)
 {
     //I want to check if 
     //data["AnElement"] is exist
 }
请提供帮助。

尝试使用
.Contains()
:-


我知道问题是关于
FormCollection
的,但是对于那些使用
FormCollection
的人来说,这里有一个解决方案

public IActionResult GetProjectDelivery(IFormCollection data)
{
    if (data.ContainsKey("AnElement"))
    {
        // do stuff
    }
    else
    {
        // do stuff
    }
}
public IActionResult GetProjectDelivery(IFormCollection data)
{
    if (data.ContainsKey("AnElement"))
    {
        // do stuff
    }
    else
    {
        // do stuff
    }
}