gpt4 book ai didi

.net - 如何命名触发事件的方法?

转载 作者:行者123 更新时间:2023-12-02 17:45:11 25 4
gpt4 key购买 nike

是否有关于如何命名在 .NET 中触发事件的方法的设计指南?在不同的示例中,我看到了以下所有内容:

OnPropertyChanged()
FirePropertyChanged()
TriggerPropertyChanged()
RaisePropertyChanged()

当然,这并不是非常重要,但我想以“正确”的方式来做,而不是用不寻常的命名约定让其他人感到困惑。 =)

最佳答案

您应该根据 MSDNCodeProjectFramework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition) 书使用 OnPropertyChanged

编辑:CodeProject 的引用仅指事件的命名,例如如果您的事件表明发生了警报,则应将其命名为 AlarmRaished

Please note that in this article, events are described as "raised" (not "fired" or "triggered"). This convention comes from the team of developers who authored much of the .NET Framework (Cwalina and Abrams, 2006). They prefer the term, "raise," because it doesn't have the negative connotations of the expressions, "fire" or "trigger."

关于.net - 如何命名触发事件的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3820424/

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