You cannot just pass an array if it is really an object []. You can easily create a new array:
var enumArray = originalArray.Cast<DataFiat>().ToArray();
If it was actually an int [] array, you can use it - although you would need to talk well with the C # compiler:
using System; class Program { enum Foo { Bar = 1, Baz = 2 } static void Main() { int[] ints = new int[] { 1, 2 }; Foo[] foos = (Foo[]) (object) ints; foreach (var foo in foos) { Console.WriteLine(foo); } } }
The C # compiler does not consider that there is a conversion from int [] to Foo [] (and there isnβt in C # rules) ... but the CLR is ok with this conversion, so since you can convince the C # compiler to play (the first time you click on an object).
This does not work when the original array is really an object [].
Hope this helps.
Sai avinash
source share