作者tylersoooong (qq33)
看板C_Sharp
標題[問題] 關於IntPtr a 存入二維與一維矩陣
時間Wed Aug 17 12:11:47 2016
大家好!
小弟為c#新手,遇到了幾個問題想請教各位
首先我有一個結構,長得像下面這樣
public class ODBSD
{
public IntPtr chadata;
public IntPtr count;
}
我想要分別把chadata 與 count 存到如下矩陣
ushort[,] chadata = new ushort[8, 50000];
long[] count = new long[8];
試了許久一直找不到方法QQ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.123.121.52
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1471407109.A.669.html
→ ssccg: 你有要用IntPtr不能直接用Array的理由嗎? 08/17 12:41
推 zenuo: Marshal.Copy(countPtr,count,0,count.length) 08/17 14:01
→ tylersoooong: s大好,因為這結構是從library來的,所以沒考慮到去 08/17 14:47
→ tylersoooong: 改它的型態 08/17 14:48
→ tylersoooong: 謝謝,z大!我試看看。 08/17 14:48