mercredi 22 septembre 2021

¿How to get a list of the properties set in C#? [duplicate]

I have a class Project like this

class Project
{
   public int IdProyecto { get; set; }
   public string Nombre { get; set; }
   public string Descripcion { get; set; }
   public string Distrito { get; set; }
   public string Provincia { get; set; }
   public string Departamento { get; set; }
   
   public List<string> GetSetProperties ()
   {
          ///
   }
}

Project project = new Project();
project.Nombre = "Project name";
project.Distrito = "District";

Console.Write(project.GetSetProperties()); // this should print: [Nombre, Distrito];

I would like to get only the properties that were set.

can you help me?





Aucun commentaire:

Enregistrer un commentaire