Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# multi casting example

Tags:

c#

.net

casting

Could someone write this literally for me so I can understand how the casting is being carried out? The amount of brackets confuses me.

(Dictionary<String, String>)((Object[])e.Result)[1];

Was only able to find simple cast examples searching (possibly means I'm searching for wrong thing) which weren't very helpful.

like image 290
negligible Avatar asked Feb 10 '12 12:02

negligible


1 Answers

Firstly, e.Result is casted to an array of type Object

(Object[])e.Result

Then, the item at index 1 in that array, [1], is casted to a Dictionary of type <string, string>

(Dictionary<String, String>)((Object[])e.Result)[1];

Hope that helped.

like image 127
Andreas Eriksson Avatar answered Sep 24 '22 18:09

Andreas Eriksson