传递一个查询字符串变量,该变量是 C# 中的关键字

Sle*_*lee 1 .net c# asp.net-mvc

我正在使用一个发布到 URL 的 API。变量之一是传递称为“事件”的变量。由于 event 是 C# 中的关键字,我的代码被它挂住了。

public ActionResult Index(string event,string email, string category, string reason, string response, string type, string status)
        {
            return View();
        }
Run Code Online (Sandbox Code Playgroud)

解决这个问题的方法是什么?

Sec*_*one 5

关键字通常不能用于参数名称。但是您可以将定义更改为:

public ActionResult Index(string @event, string email, ...) {
Run Code Online (Sandbox Code Playgroud)