jeudi 12 juillet 2018

Get properties by reflection, but only user made propertes in c#

I'm doing something using reflection in recursive function.

I want to get the properties that only I made.

public class Sample
{
    string versionInfo { get; set; } = "0.1.2.3";
}

var props_1 = typeof(Sample).GetProperties();
var props_2 = typeof(string).GetProperties();

I mean, I want to get one property in props_1 and I don't want to get any properties in props_2 because I didn't make anything to string type.

I've done something using "BindingFlags". But I can't get what I want to do it.

Please give me a wisdom you have.

Thank you.





Aucun commentaire:

Enregistrer un commentaire