Is it possible to add an attribute to a property in a partial class?

前端 未结 4 562
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 00:53

I don\'t think it\'s possible but since I haven\'t got a definite clarity from MSDN, I feel that it\'s best to ask. Suppose that we have a class as follows.

         


        
4条回答
  •  时光取名叫无心
    2020-12-07 01:37

    No, you can't.

    You can only attach attributes to members you declare there and then, and unless the member is also declared as partial (so that you may reimplement it elsewhere) you cannot attach attributes to members declared in another partial file.

提交回复
热议问题