问题描述
每次我尝试运行程序时都会收到此错误
错误CS0053可访问性不一致:属性类型实习生的可访问性低于属性frm3Update.TraineeUpdate
请帮助
我尝试了什么:
来自第二张表单的按钮
Each time i try to run programme i get this error
ErrorCS0053Inconsistent accessibility: property type 'Trainee' is less accessible than property 'frm3Update.TraineeUpdate'
please help
What I have tried:
Button from second form
private void BtnUpdate_Click(object sender, EventArgs e)
{
if (Candidate.Count == 0)
{
MessageBox.Show("There is nothing to update.");
}
else
{
FrmUpdate my = new FrmUpdate();
icnt1 = DGTrainee.CurrentCell.RowIndex;
my.TraineeUpdate = Candidate[icnt1];
my.ShowDialog();
Candidate[icnt1] = my.TraineeUpdate;
}
}
public partial class frm3Update : Form
{
public frm3Update()
{
InitializeComponent();
}
private Trainee mUpdateTrainee;
public Trainee TraineeUpdate
{
get { return mUpdateTrainee; }
set { mUpdateTrainee = value; }
}
private void frm3Update_Load(object sender, EventArgs e)
{
txtName.Text = TraineeUpdate.Name;
txtSurname.Text = TraineeUpdate.Surname;
nudAge.Value = TraineeUpdate.Age;
txtTrainingExp.Text = TraineeUpdate.Experience;
txtGender.Text = TraineeUpdate.Gender;
}
private void btnUpdateTrainee_Click(object sender, EventArgs e)
{
TraineeUpdate.Name = txtName.Text;
TraineeUpdate.Surname = txtSurname.Text;
TraineeUpdate.Gender = txtGender.Text;
TraineeUpdate.Age = Convert.ToInt32(nudAge.Value);
TraineeUpdate.Experience = txtTrainingExp.Text;
this.Close();
}
}
推荐答案
公共构造必须返回可公开访问的对象。有关详细信息,请参阅 [ ] 。
A public construct must return a publicly accessible object. For more information, see Access Modifiers (C# Programming Guide)[^].
所以,物业类型'实习生'比财产'frm3Update.TraineeUpdate'更难以获取,这就是说这是你的问题:
So, "property type 'Trainee' is less accessible than property 'frm3Update.TraineeUpdate'" is say that this is your problem:
private Trainee mUpdateTrainee;
public Trainee TraineeUpdate
{
get { return mUpdateTrainee; }
set { mUpdateTrainee = value; }
}
Traniee
类(未提供)未标有 public
accessor。
The Traniee
class (not provided) is not marked with a public
accessor.
这篇关于可访问性不一致如何解决不一致的可访问性C#问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!