Open wo80 opened 8 years ago
Try this: http://stackoverflow.com/questions/11002523/activator-createinstance-with-optional-parameters
-----Original Message----- From: "wo80" notifications@github.com Sent: 18/02/2016 7:16 AM To: "mathnet/mathnet-numerics" mathnet-numerics@noreply.github.com Subject: [mathnet-numerics] MILU0Preconditioner constructor (#377)
A parameterless constructor should be added, so instead of having only MILU0Preconditioner(bool modified = true)there should be MILU0Preconditioner() : this(true) MILU0Preconditioner(bool modified)Without a parameterless constructor, the following code (used for automated testing) will throw an exception.: var preconditioner = Activator.CreateInstance(typeof(MILU0));— Reply to this email directly or view it on GitHub.
@kjbartel: Thanks for the tip. Works great.
EDIT: the above solution throws for classes that only have one parameterless constructor, so that's not an option.
A parameterless constructor should be added, so instead of having only
there should be
Without a parameterless constructor, the following code (used for automated testing) will throw an exception.:
EDIT: Maybe the second constructor should be dropped. One can use object initializers instead: