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 8307191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:28:39+00:00 2026-06-08T18:28:39+00:00

I am trying to learn to serialize XML files and I have hit a

  • 0

I am trying to learn to serialize XML files and I have hit a snag on accessing a variable that is inside a Class that is inside a List. Here is the declaration code:

public class Library{
    public string name;
    public List<Book> books;
}

public class Book{
    public string name;
}

Here is the code where I populate the List that I’m going to serialize, but whenever I run this code all of the library.books.name always end up being equal to the last thing I saved book as, in this case “Xenocide”.

    public void MakeXML(){
        Library library = new Library();
        library.books = new List<Book>();       
        library.name = "Red";
        Book book = new Book();
        book.name = "Hobbit";
        library.books.Add(book);
        book.name = "Xenocide";
        library.books.Add(book);
    }

I was wondering if there is a way to acess the variable name inside the Class Book inside the List books, but I can’t seem to find something. Any help would be appreciated, Thanks.

  • 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-08T18:28:40+00:00Added an answer on June 8, 2026 at 6:28 pm

    As simple as:

    library.books[0].name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to learn class-based views, for a detail or list view is not
Trying to learn jquery here so I took a regular javascript snippet that loops
Trying to learn Regex in Python to find words that have consecutive vowel-consonant or
Trying to learn some geospatial python. More or less following the class notes here
Trying to learn how to use Data.Binary and hit a roadblock here: http://www.haskell.org/haskellwiki/Serialisation_and_compression_with_Data_Binary D:\Projects\haskell\serialize\ex1.hs:114:26:
Trying to learn about php's arrays today. I have a set of arrays like
im trying to learn delegates and events in c#, i understand that an event
Im trying to learn a bit about c++ and have run in to some
Actually I am trying to learn jQuery Ajax calls to asp.Net webservices. I have
Trying to learn PL/SQL with multimedia data. Can anyone please point out that from

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.