gpt4 book ai didi

c# - 紧急错误cs0542成员名称不能与它们的封闭类型相同

转载 作者:行者123 更新时间:2023-12-02 10:56:44 31 4
gpt4 key购买 nike

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pokemon.Overworld
{
public struct Location
{
/// <summary>
/// </summary>
public int Region;
/// <summary>
/// </summary>
//public int Generation;
public int[] Versions;
/// <summary>
/// </summary>
public int Area;
/// <summary>
/// </summary>
public Locations Location;
/// <summary>
/// </summary>
public int MatrixId;
/// <summary>
/// </summary>
/// Town, Route, Dungeon, Underground, Safari
/// ToDo: C? P? W? Union? Direct?
public int Type;
}
}

我收到此错误,不知道如何解决。

error CS0542: `Pokemon.Overworld.Location.Location': member names cannot be the same as their enclosing type the error is at line 22,20

最佳答案

该错误非常具有描述性。您有一个属性(property)
public Locations Location;
而且您的结构名称也是

public struct Location

将属性 Location更改为 Locations,它应该起作用。但更重要的是,您应该了解 的原因。

关于c# - 紧急错误cs0542成员名称不能与它们的封闭类型相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61200326/

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