Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why do we know that to be false? The line</p> <pre><code>Database testDatabase = sampleDatabaseList[0]; </code></pre> <p>invokes the indexer with the parameter <code>0</code> which is a <code>int</code> literal and therefore, seeing that <code>DatabaseList</code> inherits from <code>HierarchialItemList&lt;Database&gt;</code> will invoke the indexer defined by</p> <pre><code>public ItemType this[Int32 itemCode] { get; } </code></pre> <p>which is declared to return an <code>ItemType</code>. You haven't told us what <code>ItemType</code> is. We have no reason to know that an <code>ItemType</code> can be assigned to a variable of type <code>Database</code>.</p> <p>Indexers do not have to return the same type. However, it is not possible to overload solely on the basis of return type. That is, this is legal</p> <pre><code>class IndexerTest { public int this[int index] { get { return 0; } } public string this[double index] { get { return "Hello, success!"; } } } </code></pre> <p>This is not</p> <pre><code>class IndexerTest { public int this[int index] { get { return 0; } } public string this[int index] { get { return "Hello, fail!"; } } } </code></pre> <p>Responding to your edit:</p> <blockquote> <p>Edit: I just figured out that it's because of using an enumeration as an indexer which is internally an integer. Still, any way to use both an enumeration and an integer?</p> </blockquote> <p>If you want to invoke the indexer that accepts an enum, invoke it like so:</p> <pre><code>sampleDatabaseList[Environments.RMSEnvironment.SomeEnumValue]; </code></pre>
    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. 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