C#: how to return a list of the names of all properties of an object?

前端 未结 4 476
太阳男子
太阳男子 2021-01-29 00:48

I have a class:

 public class foo
{
    public IEnumerable stst_soldToALTKN { get; set; }
    public int sId { get; set; }        
    public strin         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 01:35

    You could try

    var propertyNames = foo1.GetType()
                       .GetProperties()
                       .Select(x => x.Name).ToList();
    

提交回复
热议问题