开发者

Reverting from an automatic property to regular property in C#4.0

Can anyone explain me how to revert from automatic implemented poperty (AIP)A to regular property.

For eg. iF i have declared a AIP, then how to make it regular (how t开发者_StackOverflow中文版o write some code in get and set accessor method.)

Thanks in advance !!!


AIP can be used only "when no additional logic is required in the property accessors" so, to revert them, just declare them the "old way": define a private property (if needed) and put the needed code in your property accessors blocks.


You could do something like this to get your job done
public String YourProperty { get { //append your business logic for the property here return something after some calculation //e.g. area of a geometric figure
} set { // Append your logic her fir e.g concatenation of firstname and lastname //(Firstname + Lastname); } }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜