G
Guest
If I have a byte[] how would I port code from C++ to manipulate the byte
array as if it were a long[]?
For example:
// C++
// assume the following
// unsigned char* m_pPalette;
// unsigned char* m_pData;
//
DWORD* pDest= (DWORD*)m_pData;
DWORD* pSrc = (DWORD*)m_pPalette;
int i;
for (i = 0; i < iLenData; i++)
pDest = pSrc;
// C#
// assume
// byte[] pData
// byte[] m_pModifiedData
// byte[] m_pPalette
//
unsafe
{
fixed(byte* dest = m_pModifiedData, src = m_pPalette)
{
int i;
for(i=0;i<length;i++)
(long[])dest = (long[])src[pData];
}
}
I'm trying to manipulate the memory directly to the m_pModifiedData without
having to do a System.Buffer.BlockCopy to another array and then back again
in my member variable after the manipulation.
Is this possible?
Thanks
Dennis
array as if it were a long[]?
For example:
// C++
// assume the following
// unsigned char* m_pPalette;
// unsigned char* m_pData;
//
DWORD* pDest= (DWORD*)m_pData;
DWORD* pSrc = (DWORD*)m_pPalette;
int i;
for (i = 0; i < iLenData; i++)
pDest = pSrc;
// C#
// assume
// byte[] pData
// byte[] m_pModifiedData
// byte[] m_pPalette
//
unsafe
{
fixed(byte* dest = m_pModifiedData, src = m_pPalette)
{
int i;
for(i=0;i<length;i++)
(long[])dest = (long[])src[pData];
}
}
I'm trying to manipulate the memory directly to the m_pModifiedData without
having to do a System.Buffer.BlockCopy to another array and then back again
in my member variable after the manipulation.
Is this possible?
Thanks
Dennis