Whats the need to incude other class as member of class [Resolved]

Posted by Swappy_Gaj under ASP.NET MVC on 1/28/2015 | Points: 10 | Views : 1311 | Status : [Member] | Replies : 2
Here the Genre and Artist are two different classes.
In Album class both classes are included i.e.;line number:9 and 10
public Genre Genre{get;set;} and
public Artist Artist{get;set;}
Whats the use of thsi classes inside Album class.

Please help:

1. public class Album
2. {
3. public int AlbumId { get; set;
4. public int GenreId { get; set; }
5. public int ArtistId { get; set; }
6. public string Title { get; set; }
7. public decimal Price { get; set; }
8. public string AlbumArtUrl { get; set; }
9. public Genre Genre { get; set; }
10. public Artist Artist { get; set; }


Posted by: kgovindarao523-21772 on: 1/28/2015 [Member] [MVP] Bronze | Points: 50



Think in a real time scenario.
If you have a movie album, which was composed by a music director.
In Album class you can see the album details which you said like Title, Price etc.
If you want to know about music director , those details will be available in Artist Class.

Suppose three albums composed by the same music director, you cant repeat his details in album class. so store details in Artist class and refer here.

Thank you,

Swappy_Gaj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Swappy_Gaj on: 1/28/2015 [Member] Starter | Points: 25

awesome thanks
please give a suitable example

Swappy_Gaj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response