What is the use of get set properties in C#?

Last Reply on Jun 21, 2014 01:22 AM By Azim

Posted on Jun 21, 2014 01:18 AM

why we have to use get and set properties in our application,

public int i=0; // we can put int as a public
then why we use get and set properties, what is the main use of that

Posted on Jun 21, 2014 01:22 AM

Properties are members that provide a flexible mechanism to read, write, or compute the values of private fields.

This enables data to be accessed easily while still providing the safety and flexibility of methods.