Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   convert memcpy() C++ to C# (http://www.go4expert.com/forums/convert-memcpy-cpp-c-sharp-t21855/)

Yo123456 21Apr2010 14:42

convert memcpy() C++ to C#
 
C++ code(working)
{
void CALLBACK MessageCallback(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser)

NET_DVR_ALARMINFO m_struAlarmInfo;
memcpy(&m_struAlarmInfo, pAlarmInfo, sizeof(NET_DVR_ALARMINFO));
}

C# code (Not working)
{
public void MessageCallback(Int32 lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, [MarshalAs(UnmanagedType.LPStr)] string pAlarmInfo, UInt32 dwBufLen, IntPtr pUser)

CHCNetSDK.NET_DVR_ALARMINFO m_struAlarmInfo;
Array.Copy(m_struAlarmInfo, pAlarmInfo.ToCharArray(), (int)dwBufLen);
}
Some how for the C# code cannot work when i debug the code it will give me error


Error 1:The best overloaded method match for 'System.Array.Copy(System.Array, System.Array, int)' has some invalid arguments

Error 2 :Argument '1': cannot convert from 'AlarmMgtApps.CHCNetSDK.NET_DVR_ALARMINFO' to 'System.Array'

anyone keen to help?


All times are GMT +5.5. The time now is 00:22.