mercredi 3 juin 2015

How to use this object using reflection

I am using following class that I need to instantiate and set its properties.

public class Employee
    {
        public int Id { get; }
        public string Name { get; }
        public Dictionary<int, string> Data { get; }
    }

I can instantiate the object as follows but I don't see anyway of setting the properties. Any ideas?

Employee employee = (Employee)FormatterServices.GetUninitializedObject(typeof(Employee)); 





Aucun commentaire:

Enregistrer un commentaire