Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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:</p> <pre><code>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; } } </code></pre> <p>And then I would use a generic collection (such as a <a href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" rel="nofollow noreferrer"><code>List&lt;T&gt;</code></a>) to hold instances of that structure:</p> <pre><code>List&lt;FileInfo&gt; myFiles = new List&lt;FileInfo&gt;(); </code></pre> <p>Alternatively, you could use a <a href="http://msdn.microsoft.com/en-us/library/xfhwa508.aspx" rel="nofollow noreferrer"><code>Dictionary&lt;TKey, TValue&gt;</code></a>, with the <code>FileId</code> as the key and the <code>FileInfo</code> structure as the value. For example:</p> <pre><code>Dictionary&lt;int, FileInfo&gt; myFiles = new Dictionary&lt;int, FileInfo&gt;(); </code></pre> <p>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.</p> <p><strong>EDIT:</strong> Note that <a href="https://stackoverflow.com/questions/441309/why-are-mutable-structs-evil">mutable structs are evil</a>. 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 <code>CustomFileInfo</code> as a <code>class</code> instead of a <code>struct</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload