i'm learning C# and i can't understand what is the difference:
a) public int value { get; set; }
b) public int value
i think it have more sense
public int value { get {return "data:"+somevalue;}}
i'm learning C# and i can't understand what is the difference:
a) public int value { get; set; }
b) public int value
i think it have more sense
public int value { get {return "data:"+somevalue;}}
One is property and another is a field. Equivalent of property in Java is get, set method. So, in nutshell, "public int value" create a field/attribute in your class. Whereas "public int value { get; set; }" will create a private field/attribute and two public methods to get(read) and set(write) that field/attribute in class. So, it gives safer way to access your field/attribute.