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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:43:08+00:00 2026-05-20T22:43:08+00:00

Novice question. What collection type should I use to store such structure? Files collection

  • 0

Novice question. What collection type should I use to store such structure?

Files collection
---------------
FileId: Int
FileName : String
Path: String

I will need to store several files data into that collection, find Path by FileId field, delete item by FileId field.

  • 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-05-20T22:43:09+00:00Added an answer on May 20, 2026 at 10:43 pm

    Since you have several pre-defined pieces of information that you want associated with each value instance, I would start by defining a structure to hold the information required for each file:

    public struct CustomFileInfo  //pick a name that avoids conflicts with System.IO
    {
        public readonly int FileId;
        public readonly string FileName;
        public readonly string Path;
    
        // constructor
        public CustomFileInfo(int fileId, string fileName, string path)
        {
            this.FileId = fileId;
            this.FileName = fileName;
            this.Path = path;
        }
    }
    

    And then I would use a generic collection (such as a List<T>) to hold instances of that structure:

    List<FileInfo> myFiles = new List<FileInfo>();
    

    Alternatively, you could use a Dictionary<TKey, TValue>, with the FileId as the key and the FileInfo structure as the value. For example:

    Dictionary<int, FileInfo> myFiles = new Dictionary<int, FileInfo>();
    

    The advantage of a dictionary is that it provides faster lookup time when searching for a file by its ID. This is because a dictionary is implemented internally using a hash table.

    EDIT: Note that mutable structs are evil. If you need to be able to change the individual pieces of information that describe a file (and I can’t imagine why you would), you should declare CustomFileInfo as a class instead of a struct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My apologies for asking such a novice question but, I need help building a
Such a novice question, but I can't seem to resolve this. if I have
It's a novice question so be kind to me :) How can I consume
I have a very novice question, so apologies if the answer to this is
I apologize for the novice question but I'm trying to get oriented with OpenJDK.
This is a really novice question, but I don't write C unless (err, if)
A very specific question from a novice to TDD : I separate my tests
I am a novice programmer and apologize upfront for the complicated question. I am
Simple (probably stupid) question. I'm a Powershell novice and am mainly using it to
I feel like a novice for asking this question -- but why is it

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.