What are Properties in C-sharp and how to use them?

In this article I will explain the property in C# along with practical demonstration which will help you to understand it in a simple way.

Properties are used to get or set the value of data members of a class.
  • They are used to implement data security.
  • A property contains two blocks: (i) get and (ii) set. These blocks works on the basis of calling conventions.
  • get and set block is implicit calling of grammar language. Property is define public normally to have get and set control.
  • For each data members we have to create one property.
  • In c-sharp we create indexers in place of parameterized property. (In VB you can have parameterized property).
  • For static data member static properties are used.
Difference between Property and Methods

Property
  1. Property is implicitly called using calling convention
  2. Property works on compile and runtime.
Method
  1. Method is explicitly called
  2. Methods works on runtime.
Practical: Showing how to use property

see full detail: http://www.c-sharpcorner.com/UploadFile/puranindia/PropertiesInC-sharp05192009021149AM/PropertiesInC-sharp.aspx

Comments

Popular posts from this blog

Asynchronous Socket Programming in C#

Url Routing MVC TUTORIAL

WCF Chat Sample