开发者

Array of tuple not working

开发者 https://www.devze.com 2023-01-10 20:27 出处:网络
this snippet of code Tuple<int,double>[, ,] myArray = new Tuple<int, double> () [xsize, ysize, zsize];

this snippet of code

Tuple<int,double>[, ,] myArray = new Tuple<int, double> () [xsize, ysize, zsize];

returns this error

Cannot apply indexing with [] to an expression of type 'Tuple'

Where I'm using Tuple structure a开发者_高级运维s defined here.

Thank you for your help and many thanks to this website authors, this site helps me a lot for my day to day work.


I'm guessing that you want this:

Tuple<int,double>[, ,] myArray = new Tuple<int, double>[xsize, ysize, zsize];
                                                       ↑
                               note: removed the () ───┘


Creating an array is slightly different from creating any other object in that you don't specify an argument list for the constructor. Remove the () after the new Tuple<int, double> to fix your issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号