gpt4 book ai didi

c# - 是否可以更改值类型变量的默认值?

转载 作者:太空宇宙 更新时间:2023-11-03 18:05:56 25 4
gpt4 key购买 nike

<分区>

我只是想知道,是否可以更改默认值,例如C# 中的 int,我可以有一个值 -1 而不是 0。

public class Foo {
public int i;
}
...
foo = new Foo();
Console.Write(foo.i);

所以这段代码必须返回

-1

没有显式初始化

public class Foo {
public int i = -1;
}

我能否始终确定,有人不会在某处打印类似的东西

#define TRUE FALSE

但对于默认值 int

附言仅供引用。

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