mardi 21 juin 2022

C# How to create an instance of private nested class with parameters using Expression [closed]

Given the class below:

public class MyClass {
    ...
    private class NestedClass(MyClass param1, double param2, double param3, bool param4) {
        public int Property1 { get; }
        public int Property2 { get; }
    }
}

I can't access NestedClass since it is private. Still I'd like to use it. Which is the best way to instantiate the NestedClass and have access to its property? Would it be possible to achieve the result using compiled expressions maybe?

Thanks in advance for your help. Cheers. M.





Aucun commentaire:

Enregistrer un commentaire