The name X does not exist in the current context error

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

George O'Gorman

Guest
Hello. I'm trying to develop an app in which a string array is initiated in a class, then accessed in a form, but I'm getting "The name VARIABLE does not exist in the current context". I can move the array initiation to the form, and the error does not appear. It is a Windows Forms App (.NET Framework).

Class.cs

class Armour
{
public static string[] Item = new string[5];
string[] Power = new string[] { "one", "two", "three", "four", "five" };

public void CreateItem()
{

Item[0] = Power[0];
}



Form2.cs

public partial class DungeonCreation : Form
{
public DungeonCreation()
{
InitializeComponent();
}


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

Continue reading...
 
Back
Top