If I had this code:
public virtual void Foo()
{
void Bar()
{
// do important stuff for Foo
}
}
// In a child class:
public override void Foo()
{
Bar(); // Doesn't work
base.Bar(); // Also doesn't work
}
Is there anyway to call the local function defined in Bar
inside of Foo
without making Bar
a normal method?
There is no by-design way. That's what "local" means. A local is accessible by name only by code in the location of the declaration; that's why they're called "locals".
Is there "any" way? Sure, you could do all kinds of shenanigans with reflection and decompilation and unsafe code and so on. Please don't. Those are implementation details of the compiler; don't try to reverse-engineer them and certainly do not rely on any implementation choice the compiler team has made being permanent!