【问题标题】:URGENCE Error cs0542 member names cannot be the same as their enclosing typeURGENCE 错误 cs0542 成员名称不能与其封闭类型相同
【发布时间】:2020-07-26 17:54:30
【问题描述】:
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;
    }
}

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

错误 CS0542:`Pokemon.Overworld.Location.Location':成员名称不能与其封闭类型相同 错误在第 22,20 行

【问题讨论】:

  • 没有人试图阅读异常消息:(

标签: c# visual-studio unity3d visual-c++ compiler-errors


【解决方案1】:

该错误非常具有描述性。你有一个属性

public Locations Location;

你的结构名称也是

public struct Location

将属性Location 更改为Locations,它应该可以工作。但更重要的是,您应该了解为什么

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-05
    • 2012-04-21
    • 1970-01-01
    • 2020-08-24
    • 2012-05-29
    相关资源
    最近更新 更多