本文介绍了糟糕的编程风格,通过使用get访问器来更改对象的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我怀疑为什么以下代码是错误的编程风格。它来自MSDN文档



使用
获取
访问者。例如,每次访问
数字字段时,以下访问器都会产生更改对象状态的副作用。




解决方案

Hello

I had a doubt as to why the following code is a bad programming style . It is from MSDN Documentation

It is a bad programming style to change the state of the object by using the get accessor. For example, the following accessor produces the side effect of changing the state of the object every time that thenumber field is accessed.

解决方案


这篇关于糟糕的编程风格,通过使用get访问器来更改对象的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 12:15