gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 19:12:12 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com