dimanche 2 août 2020

How get property value with reflection in C#

I have a date-time variable like this:

DateTime myDate=DateTime.Now; // result is like this: 8/2/2020 12:54:07 PM

and I want to get myDate variable like this

DateTime getOnlyDate=myDate.Date; 

and I want to get myDate.Date; with reflection how can I get Date property value with reflection? with reflection I do something like this:

PropertyInfo myDate = typeof(DateTime).GetProperty("Date");

but I don`t know how can I request myDate.Date; value with reflection. thanks in advance





Aucun commentaire:

Enregistrer un commentaire