Passing by reference

Jedhi

Well-known member
Joined
Oct 2, 2003
Messages
127
void Function 1 ()
{
BYTE bVer = 0;
BYTE bSecurity = 0;
Master = Function2(&bVer, &bSecurity);
if (Master)
DoSomething_With_bVer_and_bSecurity;
}

BOOL Function2(BYTE *ver, BYTE *security )
{
static BYTE buffer[100];
*ver = buffer[3];
*security = buffer[3+1];
if ((*security) & FF0F)
return (TRUE);
else
return (FALSE);
}

Ive tried to write this in c#, but I get error because I try to convert a ref to to a byte[]. Can somebody convert this to C# ??
 
Code:
void Function1()
{
	byte version;
	byte security;
	bool master = Function2(out version, out security);
	if(master)
	{
		//DoSomething_With_bVer_and_bSecurity;
	}
}

bool Function2(out byte version, out byte security)
{
	byte[] buffer = new byte[100];
	version = buffer[3];
	security = buffer[3+1];
	if((security & 0xFF0F) != 0)
		return true;
	else
		return false;
}

might want to check out C# Programmers Reference -- Passing Parameters
 
Back
Top