gpt4 book ai didi

c# - 为什么我不能数据绑定(bind)到一个字段?

转载 作者:行者123 更新时间:2023-11-30 14:05:14 25 4
gpt4 key购买 nike

我刚刚(艰难地)了解到数据绑定(bind)不适用于字段。考虑到自动属性的简单性,这不是问题,但我想知道为什么会这样。谁能解释一下?

最佳答案

我找到了一个很好的解释here :

... because public fields are not a recommended practice. While they maybe convenient for quick and dirty code, they do not version. Using properties instead allows you to change the access logic, and data storage behind the covers, as well as add validation logic when a value is assigned. Furthermore, accessing properties feels pretty much the same, and do not have any performance overhead.

关于c# - 为什么我不能数据绑定(bind)到一个字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/483148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com