Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to understand the order of operations you need to remember that the cast will be applied to the object to the right but the rules that affect WHEN it is applied depends on MSDN's <a href="http://msdn.microsoft.com/en-us/library/aa691323%28v=vs.71%29.aspx" rel="nofollow">Operator precedence and associativity</a></p> <pre><code>(Dictionary&lt;String, String&gt;)((Object[])e.Result)[1]; </code></pre> <p>Becomes</p> <pre><code>Object[] cast1 = (Object[]) e.Result; </code></pre> <p>The cast operation is grouped into the "Unary Operators" category which is a lower priority than the indexer - [] which is in the "Primary expressions" category.</p> <p>In the original line - The ()'s are necessary around the cast: ((Object[])e.Result) because the indexer - [] is applied immediately to the object on the left as the first priority. Without the surrounding ()'s the cast would be applied AFTER the indexer and since e.Result is (likely?) of type object this will fail at compile time. Without the ()'s the line would look like: </p> <pre><code>(Object[])e.Result[1] </code></pre> <p>Which would not be valid.</p> <pre><code>((Object[])e.Result)[1] </code></pre> <p>ensures that e.Result is cast to type Object[] first, and then the indexer is used to access the first element.</p> <p>The second cast turns the first element of the casted object[] (in my example cast 1) into a Dictionary</p> <pre><code>Dictionary&lt;String, String&gt; cast2 = (Dictionary&lt;String, String&gt;) cast1[1]; </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.
    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