으로 변환합니다. 코드를 C++에서 C#으로 변환하려고하는데, 막혔습니다. 누군가 내가 내가 틀린 곳을 알려주실 수 있습니까? 내가 제대로 해냈다했다 확실하지 않다코드 조각을 C++에서 C#
void CALLBACK Test(void *buffer, DWORD length)
{
BYTE *b=(BYTE*)buffer, temp[20000];
DWORD p=0;
while (p<length)
{
DWORD c=min(length-p, sizeof(temp));
memcpy(temp, b+p, c);
c=SendData(dummy, temp, c);
if (c==-1) break;
p+=c;
}
}
where is SendData(int, byte[], int)
그리고 현재의 C# 코드
void Test(IntPtr buffer, int length)
{
byte[] temp = new byte[20000];
byte[] b = new byte[length];
Marshal.Copy(buffer, b, 0, length);
long p=0;
while (p<length)
{
long c=Math.Min(length-p, 20000);
Array.Copy(temp, b+p, c);
c=SendData(dummy, temp, (int)c);
if (c==-1) break;
p+=c;
}
}
하지만이기 때문에 나는 b+s
에 운영자 +
를 적용 할 수 없습니다 볼 수 있습니다
C++ 코드는 long
및 byte[]
.
감사
"리터럴"변환 대신, 함수가 무엇을하는지 확인하고 C#에서 다시 작성하는 것이 더 좋다고 생각하지 않습니까? –