mark esco

mark esco

  • NA
  • 12
  • 0

Struct Vs Class for Array Element?

Nov 24 2010 11:54 PM
Happy Thanksgiving everyone! I am very new to C#. and I made a class to store info about
media files. I need a  "structure" to hold start and end positions of certain media files. Some
media files may need 20+ sets of "start" and "End" data and some may need only 1 for the
enire duration. So what is the best way to do this. So far I have:

 namespace UsefulPlayer
{
[Serializable]
class MediaFiles
{
public string FilePath { get; set; } //Path to file
public string FileTitle { get; set; } //Title w/o path
public int FavoriteLevel { get; set; } //Sortable attribute:Favorite

public struct Markers //Clips: each media file can have multiple
{
float StartPoint;
float EndPoint;
}

//Constructor
public MediaFiles(string MediaFilePath)
{
FilePath = MediaFilePath; //Path of file <-- Passed in
FavoriteLevel = 50; //Default to 50. 1=Sucks! 100=Great!


}


}
}

Since those two variables (StartPoint and EndPoint) are so closely related to each media file I don't
want to create a seperate class for them. Should I make a list/array/collection of these structs, or
should I use something other that structs all togeather. From what I have read I should avoid structs and make a separate class but the two variable are tied closely to each media file and each media file could require multiple sets of the variables so what to I do? As I said I am a newbie so forgive my
ignorance. And thanks in advance to everyone for your patience and knowledge.  =)

Answers (3)