Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7891791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:42:27+00:00 2026-06-03T06:42:27+00:00

I have been working on a project for my c# class at school. And

  • 0

I have been working on a project for my c# class at school. And I have a very simple question I think. But I have been unable to find an answer anywhere. I keep getting results about how to make a list of structs. I want to know how to access a list inside a struct?

So here is the struct given to us by our teacher and that we must use for this assignment:

[Serializable]
struct Name
{
    public string firstName;
    public string lastName;
}

[Serializable]
struct Movie
{
    public string title;
    public string year;
    public Name director;
    public float quality;
    public string mpaaRating;
    public string genre;
    public List<Name> cast;
    public List<string> quotes;
    public List<string> keywords;
}

struct MovieList
{
    public int length;
    public Movie[] movie;
}

Now I have tried accessing quotes and keywords in the following two ways and both have produced errors:

1.

string quotes;
MovieList ML = new MovieList();

quotes = Console.ReadLine();
ML.movie[0].quotes[0] = quotes;

2.

string quotes;
MovieList ML = new MovieList();

quotes = Console.ReadLine();
ML.movie[0].quotes.Add(quotes);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:42:28+00:00Added an answer on June 3, 2026 at 6:42 am

    A struct is a Value type and as such, using a struct to carry all of this information makes it very inefficient because every time you pass it as an argument the whole contents of the struct will need to be copied, etc. a better approach would be to use a Class, which is a Reference type and it’s reference is what gets passed around.

    As far as how to access your struct members, here’s an example:

    MovieList m =new MovieList();
    m.movie = new Movie[10];
    m.movie[0].title="The Girl with the Dragon Tatoo";
    Console.WriteLine(m.movie[0].title); //The Girl with the Dragon Tatoo
    

    UPDATE:

    Showing how to access quotes:

    MovieList m =new MovieList();
    m.movie = new Movie[10];
    m.movie[0].title="The Girl with the Dragon Tatoo";
    m.movie[0].quotes = new List<string>();
    m.movie[0].quotes.Add("Hello World");
    Console.WriteLine(m.movie[0].title); //The Girl with the Dragon Tatoo
    
    Console.WriteLine(m.movie[0].quotes[0]); //Hello World
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a Java project for a class for a while
I have been working on a project in scala, but I am getting some
I have been working on a project where I have a Worker class that
I have been working with Struts for some time, but for a project I
Suppose I have this simple app working : # model class Project has_many :numbers
I have been working on a project that has 2 interfaces - windows forms
Situation I have been working on a project lately where the UI development seems
So I have been working on this project for a short while now. I
Hey so I have been working on a project that I want to be
I have been working on a web services related project for about the last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.