mercredi 21 octobre 2015

Getting list properties type using reflection

tI want get list models properties type using reflection. I have a model list and each of list property's type should required for me

List<WebParameters.Params.AnalitikButceKodlariListesiYilOutput> list = new List<WebParameters.Params.AnalitikButceKodlariListesiYilOutput>();

WebParameters.Params.AnalitikButceKodlariListesiYilOutput item = new WebParameters.Params.AnalitikButceKodlariListesiYilOutput()
            {
                KOD = "a",
                KOD_01 = "",
                KOD_02 = "d",
                KOD_03 = "c",
                KOD_04 = "d",
                BUTCE_ADI = "e",
                YIL = 2015
            };

I try this but it wasn't success.

foreach (var pObject in list)
            {
                foreach (var item2 in pObject.GetType().GetProperties())
                {
                       var type = pObject.GetType().GetProperty(item2.Name).GetType().Name;
                }
             }





Aucun commentaire:

Enregistrer un commentaire