How can I quickly up-cast object[,] into double[,]?

后端 未结 5 800
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 14:19

I using Microsoft.Office.Interop.Excel I get returned a 2D array of type object[,] which contains double for elements. Note that the i

5条回答
  •  一个人的身影
    2020-11-28 15:06

    I wouldn't say that there is one way that's faster than another so long as you don't do anything stupid. I'd say that, if you can, cast them when you access them rather than up front. Of course this depends on how you intend to access them. If you're going to index into the array more than once then the cost of unboxing might start to get too much. If you're only scanning the array once, then cast as you go.

提交回复
热议问题