简体   繁体   English

如何在C#代码中编写C函数

[英]How can write a C function in a C# code

I want to add a C file into my .NET application. 我想在我的.NET应用程序中添加一个C文件。

How can I built this? 我怎么能建造这个? How can i write unmanaged code in C#. 如何在C#中编写非托管代码。 Can someone explain with few lines code. 有人可以解释几行代码。

Thanks 谢谢

You either have to build the C file into it's own DLL and then use P/Invoke in your C# code to call them or... 您要么必须将C文件构建到自己的DLL中,然后在C#代码中使用P / Invoke来调用它们,或者......

You could also try to port the C code to C# which would give you a completely managed codebase. 您还可以尝试将C代码移植到C#,这将为您提供完全托管的代码库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM