Click here to Skip to main content
15,913,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Want know Why we use properties instead of method or else ..?
want to know all about properties.
Posted

Methods:
C# methods are class members containing code. They may have a return value and a list of parameters, as well as a generic type declaration. Like fields, methods can be static (associated with and accessed through the class) or instance (associated with and accessed through an object instance of the class).

Properties:
C# properties are class members that expose functionality of methods using the syntax of fields. They simplify the syntax of calling traditional get and set methods (a.k.a. accessor methods). Like methods, they can be static or instance.

Please have a look on answer: Method vs Property in C#[^]

Also refer some good links:
Understanding Properties in C#
[^]
Understanding Classes, Methods, and Properties in C#[^]
C#: Properties versus getter methods[^]

Properties Tutorial[^]
Properties (C# Programming Guide)[^]
Properties (C# Programming Guide)[^]
The C# Station Tutorial: Properties[^]

C# Property Examples[^]
 
Share this answer
 
v2
Check out following link
link
 
Share this answer
 
If we don't want to provide the direct access to the members of a class, we make them private. There comes the role of Properties[^].
Properties provide a safe and secure mechanism to access the private members of a class.

hope it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900