Malfist
Malfist

Reputation: 31805

Importing C methods/classes into a C# project

I have some c headers, and a c lib that I'd like to import and use in a c# project. How can I do this?

Upvotes: 1

Views: 291

Answers (2)

Joel Coehoorn
Joel Coehoorn

Reputation: 415971

What Mehrdad said.

Additionally, welcome to the wonderful world of marshalling. P/Invoke.Net is your new best friend.

Upvotes: 2

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422076

Use [System.Runtime.InteropServices.DllImport] attribute (P/Invoke):

[DllImport("dllname.dll")]
static extern void MyFunctionName();

Upvotes: 4

Related Questions