6
I have the following class:
public class Pessoa
{
    public int id { get; set; }
    public string Nome { get; set; }
    public DateTime DataNascimento { get; set; }
}
I’ve developed a method to get her properties, but I’m not getting the way I want to:
public static class Entities<TEntidade> where TEntidade : class
{
    /* Assim da certo mas não quero passar por parametro */
    public static PropertyInfo[] GetPropertiesComoNaoQuero(TEntidade e)
    {         
        var entity = Activator.CreateInstance(e.GetType()) as TEntidade;
        PropertyInfo[] properties = entity.GetType().GetProperties();
        return properties;
    }
    public static PropertyInfo[] GetPropertiesComoEUQuero()
    {         
        /* 
         * Existe alguma forma de criar essa instancia sem passar por *parametro? so sabendo que o 
         * tipo generico meu é do tipo pessoa na chamada ? 
         */
        var entity = Activator.CreateInstance() as TEntidade;
        PropertyInfo[] properties = entity.GetType().GetProperties();
        return properties;
    }
}
public class Teste
{
    PropertyInfo[] properties = Entities<Pessoa>.GetPropertiesComoEUQuero();
    Pessoa pessa = new Pessoa();
    PropertyInfo[] propertiesb = Entities<Pessoa>.GetPropertiesComoNaoQuero(pessa);
}
						
I don’t know if I can understand what the goal is. You want to instantiate a
Pessoawithin the methodInserir?– Jéf Bueno
I guess now I understand, see if that’s what I wanted in my answer.
– Maniero
Do you want to create an instance of an object just to get its properties by Reflection? If so, it wouldn’t just be using one
typeof(TEntidade).GetProperties()? I don’t see why you need the class instance there.– Leandro Godoy Rosa