Override property setter and getter

前端 未结 2 1925
谎友^
谎友^ 2020-12-20 07:35

Is there a way to override the setter and getter of an auto property with an attribute?

like this:

[CustomAttribute]
public int Value { get; set; }
<         


        
2条回答
  •  Happy的楠姐
    2020-12-20 07:48

    No. An attribute is never "executed". You would need to build a construct looking for the attribute and doing something if it's found.

    AoP (aspect oriented programming) in .NET is only possible by using third party software like PostSharp.

提交回复
热议问题