相关疑难解决方法(0)

无法使用实例引用访问成员"<method>"

我正在进入C#,我遇到了这个问题:

namespace MyDataLayer
{
    namespace Section1
    {
        public class MyClass
        {
            public class MyItem
            {
                public static string Property1{ get; set; }
            }
            public static MyItem GetItem()
            {
                MyItem theItem = new MyItem();
                theItem.Property1 = "MyValue";
                return theItem;
            }
        }
     }
 }
Run Code Online (Sandbox Code Playgroud)

我在UserControl上有这个代码:

using MyDataLayer.Section1;

public class MyClass
{
    protected void MyMethod
    {
        MyClass.MyItem oItem = new MyClass.MyItem();
        oItem = MyClass.GetItem();
        someLiteral.Text = oItem.Property1;
    }
}
Run Code Online (Sandbox Code Playgroud)

一切正常,除非我去访问Property1.智能感知只给我" ,和"作为选项.当我将鼠标移到上面时,Visual Studio给出了这样的解释:EqualsGetHashCodeGetTypeToStringoItem.Property1

MemberMyDataLayer.Section1.MyClass.MyItem.Property1.getcannot be …

c# asp.net

175
推荐指数
5
解决办法
30万
查看次数

标签 统计

asp.net ×1

c# ×1