How can I convert a list<> to a multi-dimensional array?

后端 未结 4 1697
梦如初夏
梦如初夏 2020-12-17 03:36

I have the following method signature:

public void MyFunction(Object[,] obj)

I create this object:

List&         


        
4条回答
  •  伪装坚强ぢ
    2020-12-17 04:12

    No. In fact, these aren't necessarily compatible arrays.

    [,] defines a multidimensional array. List> would correspond more to a jagged array ( object[][] ).

    The problem is that, with your original object, each List contained in the list of lists can have a different number of objects. You would need to make a multidimensional array of the largest length of the internal list, and pad with null values or something along those lines to make it match.

    提交回复
    热议问题