bobleny
07-23-2009, 12:11 PM
I'm getting this error:
A field initializer cannot reference the non-static field, method, or property...
The issue has to do with this code:
namespace Words
{
public class Wordy
{
private int maxCourses = 4;
private string[] courseArray = new string[maxCourses];
}
}
The error would be on line 7 in the above code. I've underlined the "bad" word.
courseArray is an indexer array. So:
Wordy word = new wordy();
Wordy[0] = "Good Bye World!";
You get the idea.
I'm sure it is something stupid, it all most always is...
I don't understand why it is complaining, could someone explain it to me?
Thanks!
A field initializer cannot reference the non-static field, method, or property...
The issue has to do with this code:
namespace Words
{
public class Wordy
{
private int maxCourses = 4;
private string[] courseArray = new string[maxCourses];
}
}
The error would be on line 7 in the above code. I've underlined the "bad" word.
courseArray is an indexer array. So:
Wordy word = new wordy();
Wordy[0] = "Good Bye World!";
You get the idea.
I'm sure it is something stupid, it all most always is...
I don't understand why it is complaining, could someone explain it to me?
Thanks!