可访问性不一致:属性类型是不易进入 [英] Inconsistent accessibility: property type is less accessible

查看:162
本文介绍了可访问性不一致:属性类型是不易进入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人可以用下面的错误帮助:




可访问性不一致:属性类型'Test.Delivery'比少财产访问 Test.Form1.thelivery




 民营快递thedelivery; 

公共交付thedelivery
{
{返回thedelivery; }
集合{thedelivery =价值; }
}



我不能运行程序因错误信息不一致性。



下面是我的交货类:

 命名空间测试
{
类交货
{
私人字符串名称;
私人字符串的地址;
私人的DateTime arrivalTime;

公共字符串名称
{
{返回名称; }
集合{名称=值; }
}

公共字符串地址
{
{返回地址; }
集合{地址=价值; }
}

公众的DateTime ArrivlaTime
{
{返回arrivalTime; }
集合{arrivalTime =价值; }
}

公共字符串的ToString()
{
{返回名称+地址+ arrivalTime.ToString(); }
}
}
}


解决方案

让你的类公共访问修饰符,只需添加公共类名的关键字盈

 命名空间测试
{
公共类交货
{
私人字符串名称;
私人字符串的地址;
私人的DateTime arrivalTime;

公共字符串名称
{
{返回名称; }
集合{名称=值; }
}

公共字符串地址
{
{返回地址; }
集合{地址=价值; }
}

公众的DateTime ArrivlaTime
{
{返回arrivalTime; }
集合{arrivalTime =价值; }
}

公共字符串的ToString()
{
{返回名称+地址+ arrivalTime.ToString(); }
}
}
}


Please can someone help with the following error:

Inconsistent accessibility: property type 'Test.Delivery' is less accessible than property 'Test.Form1.thelivery'

private Delivery thedelivery;

public Delivery thedelivery
{
    get { return thedelivery; }
    set { thedelivery = value; }
}

I'm not able to run the program due to the error message of inconsistency.

Here is my delivery class:

namespace Test
{
    class Delivery
    {
        private string name;
        private string address;
        private DateTime arrivalTime;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string Address
        {
            get { return address; }
            set { address = value; }
        }

        public DateTime ArrivlaTime
        {
            get { return arrivalTime; }
            set { arrivalTime = value; }
        }

        public string ToString()
        {
            { return name + address + arrivalTime.ToString(); }
        }
    }
}

解决方案

make your class public access modifier,just add public keyword infront of your class name

 namespace Test
{
  public  class Delivery
    {
        private string name;
        private string address;
        private DateTime arrivalTime;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string Address
        {
            get { return address; }
            set { address = value; }
        }

        public DateTime ArrivlaTime
        {
            get { return arrivalTime; }
            set { arrivalTime = value; }
        }

        public string ToString()
        {
            { return name + address + arrivalTime.ToString(); }
        }
    }
}

这篇关于可访问性不一致:属性类型是不易进入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆