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
.