Where does the "value" in the get/set of a variable equalling "value" come from. Is it object-related?

Recommended Answers

All 3 Replies

Value in that sense is a special keyword that represents the data type of the property being set.

public string Property123
{
  get { return _property123; }
  set { _property123 = value; }
}

In that sense "value" looks to the property where the value is being set and uses that data type. In this case it would be a string.

Oh, and it comes from:

SomeClass.Property = "abc123";

In this case 'value' is a string reading "abc123"

Property is just another method, only difference is its syntax. In Java language you dont have that syntax, you set and get values with normal public methods. i think that property methods are useful just because it makes your code more readable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.