I want to create an array of my class Word. Here is the code:
public static void Main(string[] args)
{
Word[] Wörter = new Word[5];
Wörter[0]._Word_ = "Hallo";
Wörter[1]._Word_ = "Flugzeug";
Wörter[2]._Word_ = "Automobil";
Wörter[3]._Word_ = "Musikanlage";
Wörter[4]._Word_ = "Steuerung";
}
public class Word
{
private string _Word;
private int _counter;
public string _Word_
{
get
{
return _Word;
}
set
{
_Word = value;
}
}
public int _counter_
{
get
{
return _counter;
}
set
{
_counter = 0;
}
}
}
I always get a System.NullReferenceException in this line
Wörter[0]._Word_ = "Hallo";
If I call the an instance of my class(without array), everything works fine. I think I got a problem with the array. Maybe is using an array in this situation not the best think to do. Thank you for helping!