While some have suggested a static member variable, this is not the same because of visibility. As an alternative to aquinas answer, if the closure is accepted, then this can be done:
(Note that Foo is a property, not a method, and c is "per instance".)
class F { public readonly Action Foo; public F () { int c = 0;
However, C # does not have the direct equivalent of the static variable in C.
Happy coding.
user166390
source share