Best way to go about multiple lists?

jondavis

New member
Joined
May 19, 2022
Messages
3
Programming Experience
Beginner
So my first thing I'm going to try an write in C# involves multiple lists.
I've tried a couple ways now but still not sure if I'm going about this right.
To simplify this lets say my main list is 1-10, than I have like ten more lists that could contain anyone of those ten numbers.
list 1 - 1,3,5,6,7,10
list 2 - 1,4,8,9
list 3 - 3, 7, 10
etc, etc
Is it going to be easier to just have one main list and keep calling what I need?
Or should I have a list for each one so I don't have to keep calling things.
Or should I make a new list that takes just what you need from a larger list (if you can do that)?
I was also looking at enum but I'm thinking List would be the better option now.
Most of these lists will have anywhere from like 10-30 items in it.
 
What exactly do you mean by "calling"?

If what you mean is naming a list or declaring a variable that references a list, then it really depends on what you are trying to communicate with your code. Remember that the primary job of a programmer is to communicate their ideas to other programmers (including their future selves when they come back to look at the same code months or years from now).

On other hand if what you mean by "calling" is getting a subset of items from the original list, then what is going to matter is what you do with the subset. Is it only for a transient operation where you'll have one subset for a short time, and then not ever use it again? Or is it for a longer period of time and you'll need to keep referring to multiple different subsets?
 
What exactly do you mean by "calling"?

If what you mean is naming a list or declaring a variable that references a list, then it really depends on what you are trying to communicate with your code. Remember that the primary job of a programmer is to communicate their ideas to other programmers (including their future selves when they come back to look at the same code months or years from now).

On other hand if what you mean by "calling" is getting a subset of items from the original list, then what is going to matter is what you do with the subset. Is it only for a transient operation where you'll have one subset for a short time, and then not ever use it again? Or is it for a longer period of time and you'll need to keep referring to multiple different subsets?
In the media program I have created many different columns to tag items with.


I'll do a few basic examples
--Type --| Subtype 1 | Subtype 2 | Subtype 3 | Genre
Video----Music--------Concert------Acoustic---Hard Rock
Audio----Music--------Soundtrack--------------Christian
Audio----Audiobook--Narration-----------------Sci-Fi
Video----Movies-------Animation---Trailer------Sci-Fi
Video----Educational--Church------Sermon----Christian

Each type/subtype/genre would be a List.
Yes I could show everything in each Column/List but I only want to show the ones that apply to your previous selection.
Each time I filter down to the next Column I'm not sure if I need to create a whole new list or if I just need to call/access the items I need.
Once selected I need not ask again about that column but move on to the next one.

Hope that helps explain it.
 
Last edited:
If the types, subtypes, and genres are fixed and will never be changed, then use enums. If it's user configurable where they can add more, then use a list of strings. Note that validation will be much harder with the latter.

Here's what the enums approach would look like:
C#:
class Media
{
    public string Title { get; set; }
    public DateTime Year { get; set; }
    public string Artist { get; set; }
    :
    public MediaType Type { get; set; }
    public SubType1 SubType2 { get; set; }
    public SubType2 SubType2 { get; set; }
    public Genre Genre { get; set; }
}

public enum MediaType { Video, Audio };
public enum SubType1 { None, Concert, Soundtrack, Narration, Animation, Church };
public enum SubType2 { None, Acoustic, Trailer, Sermon };
public enum Genre { None, HardRock, Christian, SciFi };
 
If the types, subtypes, and genres are fixed and will never be changed, then use enums. If it's user configurable where they can add more, then use a list of strings. Note that validation will be much harder with the latter.

Here's what the enums approach would look like:
C#:
class Media
{
    public string Title { get; set; }
    public DateTime Year { get; set; }
    public string Artist { get; set; }
    :
    public MediaType Type { get; set; }
    public SubType1 SubType2 { get; set; }
    public SubType2 SubType2 { get; set; }
    public Genre Genre { get; set; }
}

public enum MediaType { Video, Audio };
public enum SubType1 { None, Concert, Soundtrack, Narration, Animation, Church };
public enum SubType2 { None, Acoustic, Trailer, Sermon };
public enum Genre { None, HardRock, Christian, SciFi };
Thanks I'm probably making this more difficult than what it is.
But it is my first time around trying to program something so yea it might look like a mess.
I start off with an enum for the different types
Then create a List out of the Enums - I'm using the List not only for the names but to i++ or count through it for a number to select
Then I create methods to show the selection on the screen
Then I create switch methods in order to select the number you want
Then finally it prints out onto the screen and into a text file

Thanks for the help anyways :)
 
Back
Top Bottom