The problem reproes. It is a problem with parsing incomplete code.
The line that you started ( foo.
) gets parsed together with the local function on the line below. This causes the local function not to be parsed correctly, so VS doesn't know that GetFoo
is a local function any more or that it returns a Foo
.
This is likely a bug in visual studio. As a work around, you can get the intellisense to play nice in this situation by declaring GetFoo at the top of your function's scope.
void Test()
{
Foo GetFoo() => new Foo();
var foo = GetFoo();
foo.DoThing();
}
I observe the same behavior you have when placing the GetFoo
declaration below the point in which I'm trying to use it, so it would seem that order matters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.