Hey guys can anyone tell me what am I doing wrong?
I basically set up a method which has an array, it will return a specific element in the array according to an ID set within my property.
I get the following errors:
Error (wordIdFunc = 2;): Invalid token '=' in class, struct, or interface member declaration
Error (return words[wordId];): The name 'wordId' does not exist in the current context
Heres the code:
public partial class TypingTutor : Form
{
private int wordIdFunc;
public int propWordId
{
get
{
return wordIdFunc;
}
set
{
wordIdFunc = value;
}
}
wordIdFunc = 2;
public TypingTutor()
{
InitializeComponent();
}
public string Word ()
{
string[] words;
words = new string[4];
words[0] = "The";
words[1] = "dog";
words[2] = "jumps";
words[3] = "sideways.";
int wordCount = words.Length;
return words[wordId];
}
private void btnBegin_Click(object sender, EventArgs e)
{
MessageBox.Show("Word: " + Word());
}
}
Thank you. :)