gpt4 book ai didi

c# - C# 部分类错误

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

我正在使用部分类在 2 个文件之间拆分某些功能,但出现错误。我做错了什么?

A1.cs:

private partial class A
{
private string SomeProperty { get { return "SomeGeneratedString"; } }
}

A2.cs:

private partial class A
{
void SomeFunction()
{
//trying to access this.SomeProperty produces the following compiler error, at least with C# 2.0
//error CS0117: 'A' does not contain a definition for 'SomeProperty'
}
}

最佳答案

与@Andrey K 的答案相同,但用简单的术语来说

使用每个文件的“属性”窗口将所有部分类的构建操作设置为“编译”

Properties window -> Build action property

关于c# - C# 部分类错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/184970/

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