These methods, by definition, have to run before this
is constructed. This is why they must be static methods. As such, there is no real way to access this
within them.
There really isn't a way to do what you're describing.
質問
This is what I mean.
I have a class with a constructor like so:
Class() : base(GetConstructorArgument1(), GetConstructorArgument2())
{
}
Because creating the arguments in the call to base, while possible, would be very cumbersome and gross. Both of those GetConstructorArgument methods are, by necessity, static.
GetConstructorArgument2() creates an array of lambdas. In those lambdas, I want to do work on "this", the object I am constructing.
Is there any way to do that?
解決
These methods, by definition, have to run before this
is constructed. This is why they must be static methods. As such, there is no real way to access this
within them.
There really isn't a way to do what you're describing.
他のヒント
Both of those GetConstructorArgument methods are, by necessity, static.
I want to do work on "this", the object I am constructing.
You can't do both of these - if the methods are static, there is no this
to work on. Static methods belong to the class, not to the instance, so there's no instance to work with.