I am using a pre-built third party class library (think .NET Framework...) that contains a class Foo
with the following members:
public sealed class Foo {
private object _state;
public Foo(object state) { _state = state; }
}
Foo
does not contain a public
_state
setter.
In a specific scenario, I want to set the state of a Foo
object to the object itself.
This will NOT compile:
Foo f;
f = new Foo(f); // Compilation error: Use of unassigned local variable 'f'
Given the above prerequisites, is there any way that I can set the state of a Foo
object to the object itself?
Rationale The Timer
class in Windows 8.1 does not contain the Timer(AsyncCallback)
constructor which assigned the state of the Timer
object with the object itself. I am trying to port .NET code that contains this Timer
constructor to a Windows 8.1 class library, so my concern is How do I pass the object itself to its state member? This issue is further outlined here, but I thought it would be more efficient to also pose the principal question above.