I have a simple piece of code:
object[] result = this.getData("baseLogin", args);
if (result.Count() > 0)
return result[0];
Method getData returns object[] ofcourse.
Everything looks fine but result[0] gives following error:
Cannot implicitly convert type ‘object’ to ‘object[]’.
An explicit conversion exists (are you missing a cast?)
Why does it treat object[] as object and wants to convert it to object[]?
If by any chance
getDatais returning array of arrays, meaning each item in the result array is array by itself, the compiler can’t know that… you have to convert it explicitly like this:This will give run time error in case the item is something else.