這是我第一次至少使用Stackoverflow作爲提問者,而英文不是我的母語,所以請對不起我的英文。錯誤1不一致的可訪問性:
我得到這個錯誤
可訪問性不一致:字段類型 'System.Collections.Generic.List' 比場 'Agenda.Form1.listaPersonas'
我竟然發現少了訪問它在其他問題,但所有的答案說,參數必須公開,這是我不明白的東西。我仍然是一名學生,並且我瞭解到該領域的知名度必須是私密的,訪問者必須公開。無論如何,我試圖把它們私人化,但我仍然有同樣的問題。
這裏是我的代碼:
namespace Agenda
{
public partial class Form1 : Form
{
public List<Persona> listaPersonas = new List<Persona>();
public Form1()
{
InitializeComponent();
}
}
class Persona
{
private string nombre;
private string apellidos;
private string telefono;
private DateTime fechaNac;
public Persona(string nom, string ape, string tel, DateTime fecNac) {
this.nombre = nom;
this.apellidos = ape;
this.telefono = tel;
this.fechaNac = fecNac;
}
}
}
絕非類是私有的只有類是內部沒有私人 – 2014-10-18 10:06:43
沒錯真正。鍵入的速度超過思維有時suxx;) – MichaC 2014-10-18 10:11:01