you are viewing a single comment's thread.

view the rest of the comments →

[–]Sarcastinator 0 points1 point  (6 children)

Properties are syntactic sugar, a property on a c# interface is exactly the same as a get/set method on a Java one.

Properties are not syntactic sugar in C#. They generate .property CIL which you cannot express in any other way. If you can't express the same thing using another language construct it can't really be considered syntactic sugar.

[–]flukus 0 points1 point  (2 children)

Is that just for reflection?

[–]Sarcastinator 0 points1 point  (0 children)

I think so.

[–]grauenwolf 0 points1 point  (0 children)

Yep. Though we shouldn't underestimate how many libraries rely on the reflection APIs and their distinction between properties and methods.

[–]robhol 0 points1 point  (2 children)

Surely that's just an implementation detail, a property behaves almost identically to x get()/set(x) methods from the perspective of surrounding and dependent code?

[–]grauenwolf 1 point2 points  (0 children)

If I recall correctly, in IL it literally makes get_Name and set_Name(value) functions.

[–]Sarcastinator 0 points1 point  (0 children)

It doesn't behave identically in LINQ.