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

I feel like a novice for asking this question -- but why is it
Right this is a really novice question i think.. but I've not got any
public class GamePiece { public GamePiece(char cLetter, int nPointValue) { m_cLetter=cLetter; m_nPointValue=nPointValue; m_nTurnPlaced=0; //has
Recent JVM's have a lot of XX parameters for garbage collection (see here for
Following on from another question I asked, Scala 2.8 breakout , I wanted to
I'm an ASP.NET web part novice. I've built a few simple ones using only
This is a question related to how people are handling a situation in the
I'm binding a collection of objects to a listbox in WPF, for simplicity we'll
Does .net CLR typecast the objects to the ones mentioned in the collection declaration?
I have an encoding question and would like to ask for help. I notice

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.