debug = true时使用方法参数的任何方法

发布于 2025-02-11 22:21:08 字数 289 浏览 1 评论 0原文

当调试= true时,使用方法参数的任何方法,例如条件上的tribute,但对于参数:

    static void Recursion(int depth)
    {
        //.. some code here
        // .. Recursion(depth); ..
    }

对于我的情况,我需要类似的东西:

Recursion([ConditionalParameter("DEBUG")] int depth)

Any way to use method parameter when DEBUG=true, like ConditionalAttribute but for parameter:

    static void Recursion(int depth)
    {
        //.. some code here
        // .. Recursion(depth); ..
    }

For my case I need something like:

Recursion([ConditionalParameter("DEBUG")] int depth)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

葬心 2025-02-18 22:21:09

我认为您应该使用debugger.isattached与语句结合使用:

    public void Recursion(int depth) {
    if (Debugger.IsAttached) {
        //do something with depth
    }else {
        //do something without depth
    }
}

I think you should use Debugger.IsAttached in combination with an if statement:

    public void Recursion(int depth) {
    if (Debugger.IsAttached) {
        //do something with depth
    }else {
        //do something without depth
    }
}
圈圈圆圆圈圈 2025-02-18 22:21:08

您可以做:

static void Recursion(
#if DEBUG
    int depth
#endif
)
    {
        //.. some code here
        // .. Recursion(depth); ..
    }

但是我不建议这样做。

You could do:

static void Recursion(
#if DEBUG
    int depth
#endif
)
    {
        //.. some code here
        // .. Recursion(depth); ..
    }

But I wouldn't recommend it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文