Posts Encapsulate Field – Tip of week #12

Encapsulate Field – Tip of week #12

Last week I told you guys about, Extract Method. Today I am going to talk about Encapsulate Field in Refactor.

Encapsulation is very essintial part of OOPS. You can eaily encapsulate your field in using your Refactor option.

Its very simple to Encapsulate the field in you just need to right click on field – refactor – encapsulate field.



After this the output is like,

14 private bool _isValid;


16 public bool IsValid1

17 {

18 get { return _isValid; }

19 set { _isValid = value; }

20 }

So you’ll have no troubles implementing Encapsulation in your code. VS.Net does this all for you.

Enjoy Coding!!!


This post is licensed under CC BY 4.0 by the author.