How can I get Visual Studio 2017 to interactively debug this line?

I have the following code configured as a dummy example to illustrate what I found in my production code.

static void Main(string[] args)
{
    bool GreaterThan(int x, int y)
    {
        return x > y;
    }

    bool OperateOnTwoNumbers(int x, int y, Func<int, int, bool> func)
    {
        return func(x, y);
    }

    var twoGreaterThanOne = OperateOnTwoNumbers(2, 1, GreaterThan);

}

When I set the clock or debug it with Shift+F9, on OperateOnTwoNumbers(2, 1, GreaterThan), I get the following error.

Error OperateOnTwoNumbers (2, 1, GreaterThan) CS0103: the name "OperateOnTwoNumbers" does not exist in the current context

But the code itself works fine, and after I step through the line, I see the value assigned to the variable.

This has been replicated on multiple computers with production code and with this dummy example, so I don't think this is an environmental issue.

, , .

problem record

?

+4
1

, (, VS ), ).

(, GreaterThan OperateOnTwoNumbers) :

[CompilerGenerated]
internal static bool <Main>g__OperateOnTwoNumbers|0_1(int x, int y, Func<int, int, bool> func)
{
  return func(x, y);
}

:

Program.<Main>g__OperateOnTwoNumbers|0_1(...);

, , OperateOnTwoNumbers ( "" OperateOnTwoNumbers " " ), .

+2

Source: https://habr.com/ru/post/1696098/


All Articles