Closed xPaw closed 5 months ago
I don't understand what you want to do; readonly fields?
I want to pass a constructor instead of method into Run() so that it creates an instance of a class
Okay, I don't think it's a good idea, so I can't adopt that idea. If you want a return value, you can pass it out through a closure or something.
Foo foo = default!;
ConsoleApp.Run(args, (int x, int y) =>
{
foo = new Foo();
});
Console.WriteLine(foo);
I don't really want the return value, but rather for the parsed arguments to be passed into the constructor.
foo = new Foo(x, y);
.
This would allow using readonly fields in the class. Currently to do this I think I would need to have a method to accept the arguments, and then duplicate them in the class.
I'm thinking something like this:
Is this a reasonable idea?