namespace ClassLibrary1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public void MyMethod(byte[] buf)
{
int array_len=buf.GetLength(0);
Console.WriteLine("array length of parameter {0} ",array_len);
}
}
}
VC.NET usage
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
#using <ClassLibrary1.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace ClassLibrary1;
using namespace System::Windows::Forms;
// This is the entry point for this application
int _tmain(void)
{
Console::WriteLine(S"Hello masterz");
char ManageArray __gc[] = new char __gc[5];
for(int i=0;i<5;i++)
ManageArray[i]=i;
Class1 *cs = new Class1();
cs->MyMethod(ManageArray);
MessageBox::Show("This code snippet shows how to pass array to C#");
return 0;
}