I'm making the assumption that it's called variable capture because it only "captures" what it needs and doesn't keep references to everything available
That's exactly right. The compiler refactors code that closes over a variable to keep it in scope. It doesn't close over every single outer variable when an anonymous method is used.
Take the following example:
public static void Foo()
{
int i = 0;
int j = 1;
Action a = () => Console.WriteLine(i);
}
It will be turned into something like the following by the compiler:
public class ClosureClass1
{
public int i;
public void Method1()
{
Console.WriteLine(i);
}
}
public static void Foo()
{
ClosureClass1 closure = new ClosureClass1();
closure.i = 0;
int j = 1;
Action a = closure.Method1;
}
You should be able to see, from this example, why the closed over fields are accessible and the fields not closed over from an outer scope are not.