c# - why would an interface have properties in them -


why interface have property in it? understand interface contract why ever need property within interface? many thanks

well let's suppose interface represents collection of objects.

further suppose want know how many objects.

tada! use property int count {get;}

technically, never need property because can write setx() , getx() method. it's kind of true never need one.

however, frameworks use reflection find properties, frameworks serialization , deserialization. in cases, properties are needed.

in practical terms, properties more readable methods, , used should convey additional information such "it not going expensive read value" , "reading value not cause observable side-effects". (both should apply implemented property getters.)


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -