Good morning everyone. I have a problem that I believe can be solved with Reflection, but I do not know how to use it and hope they can help me through my difficulty.
I have an object that will be passed as a parameter to a specific method. This method should be able to read this generic object and identify the name of all fields of this object. Below the example.
public class Aluno
{
public int Id {get;set;}
public string Nome {get;set;}
}
The method below will receive this object and need to go through it and identify the name of the fields, that is, it needs to find that one field is called Id and the other one is named Name . Example below:
public void DescobridorDeNome(T Objeto)
{
//Aqui ele vai descobrir o nome dos campos do objeto.
}
So in this method I believe that using Reflection will solve. Does anyone know how I can do this?
Thanks.