Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>const</code> is for compile-time constants. You <em>could</em> just make it <code>static readonly</code>, but that would only apply to the <code>METRICS</code> variable itself (which should typically be Metrics instead, by <a href="http://msdn.microsoft.com/en-us/library/ms229043.aspx" rel="noreferrer">.NET naming conventions</a>). It wouldn't make the <em>list</em> immutable - so someone could call <code>METRICS.Add("shouldn't be here");</code></p> <p>You may want to use a <code>ReadOnlyCollection&lt;T&gt;</code> to wrap it. For example:</p> <pre><code>public static readonly IList&lt;String&gt; Metrics = new ReadOnlyCollection&lt;string&gt; (new List&lt;String&gt; { SourceFile.LoC, SourceFile.McCabe, SourceFile.NoM, SourceFile.NoA, SourceFile.FanOut, SourceFile.FanIn, SourceFile.Par, SourceFile.Ndc, SourceFile.Calls }); </code></pre> <p><code>ReadOnlyCollection&lt;T&gt;</code> just wraps a potentially-mutable collection, but as nothing else will have access to the <code>List&lt;T&gt;</code> afterwards, you can regard the overall collection as immutable.</p> <p>(The capitalization here is mostly guesswork - using fuller names would make them clearer, IMO.)</p> <p>Whether you declare it as <code>IList&lt;string&gt;</code>, <code>IEnumerable&lt;string&gt;</code>, <code>ReadOnlyCollection&lt;string&gt;</code> or something else is up to you... if you expect that it should only be treated as a sequence, then <code>IEnumerable&lt;string&gt;</code> would probably be most appropriate. If the order matters and you want people to be able to access it by index, <code>IList&lt;T&gt;</code> may be appropriate. If you want to make the immutability apparent, declaring it as <code>ReadOnlyCollection&lt;T&gt;</code> could be handy - but inflexible.</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