首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法使用实例引用访问成员“< Member name>”

无法使用实例引用访问成员“< Member name>”
EN

Stack Overflow用户
提问于 2009-07-08 19:11:17
回答 10查看 417.2K关注 0票数 222

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

代码语言:javascript
复制
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;
            }
        }
     }
 }

我在UserControl上有以下代码:

代码语言:javascript
复制
using MyDataLayer.Section1;

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

一切正常,除了我访问Property1的时候。智能感知只给我提供"EqualsGetHashCodeGetTypeToString“作为选项。当我把鼠标移到oItem.Property1上时,Visual Studio给了我这样的解释:

MemberMyDataLayer.Section1.MyClass.MyItem.Property1.getcannot be accessed with an instance reference, qualify it with a type name instead

我不确定这是什么意思,我用谷歌搜索了一下,但没能弄明白。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1100009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档