Click here to Skip to main content
16,020,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Each time i try to run programme i get this error

Error CS0053 Inconsistent accessibility: property type 'Trainee' is less accessible than property 'frm3Update.TraineeUpdate'

please help

What I have tried:

Button from second form
C#
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();
	}
}
Posted
Updated 10-Sep-17 15:24pm
v3

1 solution

The code does not run as the compiler error is pretty clear and preventing the code from compiling.

Here is the official documentation on the Compiler Error CS0053 (C#)[^]
Quote:
A public construct must return a publicly accessible object. For more information, see Access Modifiers (C# Programming Guide)[^].

So, "property type 'Trainee' is less accessible than property 'frm3Update.TraineeUpdate'" is say that this is your problem:
C#
private Trainee mUpdateTrainee;
public Trainee TraineeUpdate
{
    get { return mUpdateTrainee; }
    set { mUpdateTrainee = value; }
}

The Traniee class (not provided) is not marked with a public accessor.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900