inaccessible to its protection level error

  • Thread starter Thread starter George O'Gorman
  • Start date Start date
G

George O'Gorman

Guest
Hello. I am trying to assign a string from a subclass randomly by counting down with a for method by a random number, and it is giving me the "inaccessible to to its protection level" error on the sub class. Thanks!

Windows Forms App (.NET Framework) C#

public class Armour
{

string[] Power = new string[] {
"one",
"two",
"three",
"four",
"five"
};

public partial class DungeonCreation : Form
{
public static string[] Item = new string[5] { "one", "two", "three", "four", "five" };

public DungeonCreation()
{
InitializeComponent();
}
private void GenerateDungeonButton_Click(object sender, EventArgs e)
{
DungeonCreationText.Text = Item[0];
}

private void GenerateNPCButton_Click(object sender, EventArgs e)
{
DungeonCreationText.Text = "generate NPC";
}

private void GenerateWeaponButton_Click(object sender, EventArgs e)
{
//DungeonCreationText.Text = TextforDCT;
}

private void GenerateArmourButton_Click(object sender, EventArgs e)
{
Random powerrnd = new Random();
int p = powerrnd.Next(1, 5);
for (int i = 0; i < p + 1; i++)
{
Item[0] = Armour.Power; // The error is here, on Power.
}
}

Continue reading...
 
Back
Top