小编Pen*_*hev的帖子

为什么我的外部C#函数的参数列表中有"this"?

我的代码在Action方法中有以下内容:

    catch (Exception e)
    {
        log(e);
        return Content(ExceptionExtensions.GetFormattedErrorMessage(e));
    }
Run Code Online (Sandbox Code Playgroud)

调用的函数如下所示:

public static class ExceptionExtensions
{
    public static string GetFormattedErrorMessage(this Exception e)

            if (e == null)
        {
            throw new ArgumentNullException("e");
        }
Run Code Online (Sandbox Code Playgroud)

有人可以解释为什么在参数列表的开头有"this"吗?

c#

2
推荐指数
1
解决办法
83
查看次数

标签 统计

c# ×1