user7425470 user7425470 - 5 months ago 45
C# Question

Excel coordinate(s) with c#

I want an Array(not a list converted to an Array), to assign only 1 coordinate something like "A4" should be accessed like

, so I was thinking of a multidimensional array whith only one element(coordinate pair).

This is what I came up with:

private dynamic[,] _excelCoordinate;

_excelCoordinate = new[,] { { "" }, { 0 } };

But I get:

No best type found for implicitly-typed array

And maybe no extra class, for that data structure.

How should it look the correct way ?

Answer Source

You need to specify the type of the array you are creating (in this case dynamic[,]). The compiler cannot infer what the type of the array should be based on the elements (the string and the integer) provided in the array initializer.

_excelCoordinate  = new dynamic[,] { { "" }, { 0 } };