gpt4 book ai didi

c# - 按默认值初始化字段是多余的

转载 作者:可可西里 更新时间:2023-11-01 08:03:07 24 4
gpt4 key购买 nike

我真的可以信任 .NET 来初始化字段(如整数、结构等)吗?如果我仍然想初始化这些字段怎么办 - 会有什么影响?

最佳答案

C# specification p.305 (17.4.4) 上的状态

The initial value of a field, whether it be a static field or an instance field, is the default value (§12.2) of the field’s type. It is not possible to observe the value of a field before this default initialization has occurred, and a field is thus never “uninitialized”.

关于c# - 按默认值初始化字段是多余的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/268393/

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