Why do we use .NET properties instead of plain old get/set functions?

前端 未结 15 1755
自闭症患者
自闭症患者 2020-12-25 15:06

I understand the many benefits of providing an interface to access the members of a class indirectly. My question is: isn\'t that already something you can accomplish in jus

15条回答
  •  悲&欢浪女
    2020-12-25 15:20

    I believe XML Serialization only reads/writes public properties, so your get and set methods would be ignored.

    Also, if you have a generic list of objects, you can assign that to a DataGridView.DataSource and you'll get a column for each of your properties. That may be what @LPalmer was referring to.

提交回复
热议问题