fork download
  1. using System;
  2. using System.Reflection;
  3.  
  4. public class Program {
  5. public static void Main(string[] args) {
  6. var pessoa = new Pessoa { id = 1, Nome = "Nicola Bogar Uccio", DataNascimento = new DateTime(1988, 08, 24) };
  7. PropertyInfo[] properties = Entities<Pessoa>.GetPropertiesComoEUQuero();
  8. }
  9. }
  10.  
  11. public class Pessoa {
  12. public int id { get; set; }
  13. public string Nome { get; set; }
  14. public DateTime DataNascimento { get; set; }
  15. }
  16.  
  17. public static class Entities<TEntidade> where TEntidade : class {
  18. public static PropertyInfo[] GetPropertiesComoEUQuero() {
  19. var entity = Activator.CreateInstance(typeof(TEntidade)) as TEntidade;
  20. PropertyInfo[] properties = entity.GetType().GetProperties();
  21. return properties;
  22. }
  23. }
  24.  
  25. //https://pt.stackoverflow.com/q/203917/101
Success #stdin #stdout 0.01s 14488KB
stdin
Standard input is empty
stdout
Standard output is empty