gpt4 book ai didi

c# - 为什么我不能有 "public static const string S = "东西”;在我的类(class)?

转载 作者:IT王子 更新时间:2023-10-29 03:28:26 26 4
gpt4 key购买 nike

尝试编译我的类时出现错误:

The constant 'NamespaceName.ClassName.CONST_NAME' cannot be marked static.

在线:

public static const string CONST_NAME = "blah";

我可以一直用 Java 做到这一点。我究竟做错了什么?为什么它不允许我这样做?

最佳答案

const 对象总是static

关于c# - 为什么我不能有 "public static const string S = "东西”;在我的类(class)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/408192/

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