c# - 无法声明具有不同属性类型的属性

标签 c#

http://imageshack.us/f/403/kasta6.png/

在链接上,我向您展示了我程序中的所有类(class)

我的 customerframe 类中有这样的属性:

 public string firstName { get; set; }
 public string lastName { get; set; }
 public CustomerFiles.Phone phone { get; set; }
 public CustomerFiles.Email email { get; set; }
 public CustomerFiles.Address addressinfo { get; set; }
 public string city { get; set; }
 public CustomerFiles.Countries countryinfo { get; set; }
 public string street { get; set; }
 public string zipcode { get; set; }

但我的问题是,在执行此操作时,我得到指向这 4 个属性的错误

public CustomerFiles.Phone phone { get; set; }
public CustomerFiles.Email email { get; set; }
public CustomerFiles.Address addressinfo { get; set; }
public CustomerFiles.Countries countryinfo { get; set; }

错误是这样的

inconsistent accessibility property type is less accessible than property

在类里面,我将执行以下操作:

        contact.FirstName = tbFirstName.Text;
        firstName = contact.FirstName;

        contact.LastName = tbLastName.Text;
        lastName = contact.LastName;

        contact.PhoneData = tbCellPhone.Text;
        phone = contact.PhoneData;

        contact.EmailData = tbHomePhone.Text;
        email = contact.EmailData;

        //inside address class
        address.City = tbCity.Text;
        city = address.City;

        address.Country = cbCountry.Text;
       countryinfo = address.Country;

        address.Street = tbStreet.Text;
        street = address.Street;

        address.ZipCode = tbZipCode.Text;
        zipcode = address.ZipCode;

但为什么我的属性会出现问题?我该如何解决这个问题才能让它发挥作用?提前致谢

最佳答案

显然,CustomerFiles.Phone 类型(或者它的包含类型 CustomerFiles,如果它是类型而不是命名空间)没有 public 的可见性。由于您创建的返回类型的属性是公共(public)的,因此类型本身也需要是 public

关于c# - 无法声明具有不同属性类型的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8490467/

相关文章:

c# - 如何配置 C# 程序在操作系统首次启动时运行?

c# - .NET 中的堆栈是否也可能发生内存泄漏?

c# - .NET 线程问题

c# - 使用 ASP.Net Identity EntityFramwork 到现有 AspNetUsers 表,并将 ID 列设置为 UniqueIdentifier

c# - .Net Core 2.0 替代 HttpResponseBase

c# - Bot Framework Channel Emulator 上的 POST 连接 ECONNREFUSED

c# - 如何使用 ServiceStack 增量序列化和反序列化 JSON?

c# - 如何转换 Entity Framework 6 为我的模型生成 FluentAPI 定义,而不是数据注释? (我在 VS2015 中使用 MySQL)

c# - 单个 LINQ 表达式来计算数据集中的多个列

c# - 为什么默认情况下不内联自动属性?