字典中的数组<byte> ^ </byte>

时间:2012-07-10 16:46:52

标签: c++-cli

我想将数组字节中的图像数据存储到字典中。

int img_sz = img0->width * img0->height * img0->nChannels;

array <Byte>^ hh = gcnew array<Byte> (img_sz);

Marshal::Copy( (IntPtr)img->imageData, hh, 0, img_sz );

Dictionary<String^,array< Byte >^>^ myResult = gcnew Dictionary<String^,array< Byte >^>(); 

myResult->Add("OVERVIEW",hh);

一旦到达myResult-&gt;添加行(“OVERVIEW”,hh);

我得到一个:mscorlib.dll中发生了'System.ArgumentException'类型的未处理异常

1 个答案:

答案 0 :(得分:0)

检查重复的密钥。 Dictionary::Add不能用于替换现有数据。

您可以看到in the documentation right here解释的错误。它特别说

  

ArgumentException字典中已存在具有相同键的元素。

相关问题