Why int[] cannot be implicitly converted to system.Array ??
example: I wanted to do this-
int[] a=new int[5];
a=(int[])Enum.GetValues(typeof(post));
where post is an enum. Why did we require to cast LHS to int[]?? The GetValues() method returns arrays only..
VulpesPosted Jun 12, 2013, 6:58 PM
Because these values are not necessarily ints - they could be longs, shorts, bytes etc. - the method returns a generic System.Array object which then needs to be cast to its actual type so that you can deal with it like a normal array.
There is no need to create an array object separately as the method will do that for you.
So you just need:
int[] a = (int[])Enum.GetValues(typeof(post));