design patterns - C# - Member variables passed to internal methods? -


when class has internal variable, should passed methods internally, or should method 'know' it?

eg

int _someid;  private void myfunction(int id) { use id ... } 

or

private void myfunction() { use _someid ... } 

no, should use second example.

if method meant use member variable, second example correct.

if intentions use method other passed in values, other methods within class, or maybe external calls, first option do.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -