I am having issue on passing/ connecting one class Director()
in the constructor of another class Movie()
. Basically what I want to do is to have two different domain for Movie
and Director
but use instance of Director
in constructor of the Movie
class. I have a declaration of public Director director;
in the movie class but how I can pass it as constructor parameter in Movie?
void Main()
{
Director d1 = new Director("Wachowski Brothers", "USA");
Movie m1 = new Movie("Matrix", d1.Name);
Console.WriteLine(m1.Title);
}
class Movie
{
public Director director;
public string Title { get; set; }
public Movie( string title, Director directorName ){
Title = title;
}
}
class Director
{
public string Name { get; set; }
public string Nationality { get; set; }
public Director(string name, string nationality){
Name = name;
Nationality = nationality;
}
}