#pragma once using namespace System; namespace Test { public ref class Class1 { public: int Add(int i, int j) { return(i + j); } }; }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using Test;// my c++ dll refernce namespace WindowsApplication3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("Test.dll")] public static extern int Add(int a, int b); private void button1_Click(object sender, EventArgs e) { int p = Add(1, 2); } } }