What is the difference between readonly property and function in .net?

There's one important difference if you use data binding, you simply cannot bind to a method, you can only bind to properties.


The difference is more semantic that functional; a property getter is in fact a function under the hood. The difference is more that as a programmer, you often expect that calling a property getter is a very cheap operation, while calling a function could potentially be more expensive.

Note that this is not necessarily the case; you can very well implement very light-weight functions, and very heavy property getters, but as a rule of thumb, a property getter should typically do nothing much more than simply get the value.


The whole property thing was - probably - conceived to avoid getting a bunch of separate GetSomething(), SetSomething(var x) methods, which used to be the norm in, for example, Java in the early 2000s for data access. This to avoid publicly exposed variables.

Believe me, those classes looked awful. I personally think the property concept is a great leap forward in readability and structure.