Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts

Can any one convert c++ code to C#.., I am facing Problem with double Pointer..,

Here is the C++ Code...,

 LUMI_ID_ERROR LumiDeviceCtrl::GetSystemMetrics(DBGroupMetrics** pDBMets, uint &nNumActiveGroups)
{
	SetLastError("");

	if(!GoodHandle())
		return LUMI_ID_GEN_ERROR_ID_OPERATION_FAILED;

	V100_ERROR_CODE	rc = GEN_OK;
	_MX00_DB_METRICS* pSysDBMetrics = NULL;

	rc = V100_ID_Get_System_Metrics(&m_DevHdl, &pSysDBMetrics, nNumActiveGroups);
	if(GEN_OK != rc)
	{
		SetLastError(rc, "V100_ID_Get_System_Metrics");
		goto Exit;
	}

	*pDBMets = new DBGroupMetrics[nNumActiveGroups];

	_MX00_DB_METRICS* pTmpSrc = pSysDBMetrics;
	DBGroupMetrics*   pTmpDst = *pDBMets;

	for(uint ii = 0; ii < nNumActiveGroups; ++ii)
	{
		pTmpDst->nGroupID                = pTmpSrc->nGroupID;
		pTmpDst->nFlags					 = pTmpSrc->nFlags;
		pTmpDst->nMaxUsers               = pTmpSrc->nMaxUsers;
		pTmpDst->nFingersPerUser         = pTmpSrc->nFingersPerUser;
		pTmpDst->nInstancesPerFinger     = pTmpSrc->nInstancesPerFinger;
		pTmpDst->nCurEnrolledUserFingers = pTmpSrc->nCurEnrolledUserFingers;
		pTmpDst->nCurEnrolledUsers		 = pTmpSrc->nCurEnrolledUsers;

		pTmpDst++;
		pTmpSrc++;
	}

Exit:
	if(pSysDBMetrics)
		V100_ID_Release_System_Metrics(&m_DevHdl, pSysDBMetrics);

	return (LUMI_ID_ERROR)rc;
}

The above function GetSystemMetrics has a parameter DBGroupMetrics** pDBMets, DBGroupMetrics is struct

every thing is Ok but when I'm declaring array for the struct in C# I am getting Error..,
this is the line am not able to declare in the C#

*pDBMets = new DBGroupMetrics[nNumActiveGroups];

Thanks & Regards
Posted
Updated 28-Oct-10 19:24pm
v4
Comments
Richard MacCutchan 29-Oct-10 5:38am    
What error? Don't expect people to guess what your problem is, give the exact message you see.
Andreas Gieriet 29-Oct-10 5:44am    
Can you please provide the C# code too?
Maybe that this helps: A rectangular array of doubles (aka matrix) is:
double [,] = new double[iRows,iCols];
Cheers
Andi
chandrashekhar racharla 29-Oct-10 5:55am    
Problem Solved

1 solution

I think the C++ is just making sure the pDBMets is passed by reference,
it's a pointer to a pointer that will be set.
If you pass you'r pDBMets as ref (or possibly as an out) you should be able to do a normal assign.

Hope this helps,
Fredrik
 
Share this answer
 
Comments
Rajesh Anuhya 29-Oct-10 6:00am    
what do you mean by normal assign..,(without Pointers)????
Fredrik Bornander 29-Oct-10 6:12am    
Yeah, I'd stay away from pointers in C# unless you absolutely have to use them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900