“Property set method not found” error during reflection

前端 未结 3 1680
挽巷
挽巷 2021-01-07 16:56

I\'m trying to reflect over some class properties and set them programaticlly, but it looks like one of my PropertyInfo filters isn\'t working:

//Get all pub         


        
3条回答
  •  长情又很酷
    2021-01-07 17:30

    I understand the GetProperties() method so that it returns every property that has BindingFlags.GetProperty or BindingFlags.SetProperty.
    So if you want only properties that have setters you must remove the BindingFlags.GetProperty flag. But I did not tested it so I can be wrong.

    My answer got a -1. So it seems that my answer is wrong.

提交回复
热议问题