Difference between a property and variable

Sep 29 2009 6:40 PM

Can anyone explain me difference between a property and variable. I found them more or less same like both are used for storing and retrieving values.
 
I saw a code where player info has to be strored and for that some properties were declared inside a class. Property names are Name, PlayerNo, Age.
code:
private string name;
public string Name
{
get
{return name;}
set
{name =value;}
}
..................
..................
 
But we can easily do this task using variables.
So is there any advantage of using properties instead of variables.

Answers (11)