In the following code, why Library.genres[n].booklist are null at runtime for all items in Library.genres? Just like if the definitions for dramabooks and kidsbooks were not being considered for the static initialization:
static class Library
{
public static List<Genre> genres = new List<Genre>()
{
new Genre("Drama", dramabooks),
new Genre("Kids", kidsbooks)
};
public static List<Book> dramabooks = new List<Book>() {
new Book("book1"),
new Book("book2")
};
public static List<Book> kidsbooks = new List<Book>(){
new Book("book3"),
new Book("book4")
};
}
class Genre
{
string catname;
List<Book> booklist;
Genre(string catname, List<Book> booklist)
{
this.catname = catname;
this.booklist = booklist;
}
}
class Book
{
string title;
Book(string title)
{
this.title = title;
}
}