开发者

Reverse PInvoke and create a full unmanaged C# program

开发者 https://www.devze.com 2022-12-30 02:46 出处:网络
I know this is a strange question but the idea is simple: I prefer C# syntax rather than C++: -Setters and getters directly inside a property

I know this is a strange question but the idea is simple: I prefer C# syntax rather than C++: -Setters and getters directly inside a property -interfaces -foreach statement -possibility to 开发者_JAVA百科declare an implicit cast operator

other small things...

What I really don't know is if is possible to import a c++ dll (expecially std libraries) in C# if I don't use any namespace (even System)

The idea is just to write a program using everything that you will normally use in C++ (nothing from CLR so), even printf for example

Thanks for any answer


No it is not possible to simply import existing C or C++ files into a C# project. They are very different languages and cannot be mixed at the source level.

The way to mix C# and C++/C applications is at the PInvoke or COM Interop level. This works by duplicating the signatures in C# and allowing the C# compiler to determine the binary layout of the native type in order to marshal between the languages.


There's now something close to this

.NET Native compiles C# to native machine code that performs like C++. You will continue to benefit from the productivity and familiarity of the .NET Framework with the great performance of native code.

It's for Windows Store apps only (desktop apps may come in the future):

Desktop apps are a very important part of our strategy. Initially, we are focusing on Windows Store apps with .NET Native. In the longer term we will continue to improve native compilation for all .NET applications.

And

apps will get deployed on end-user devices as fully self-contained natively compiled code (when .NET Native enters production), and will not have a dependency on the .NET Framework on the target device/machine


No; this is not directly possible. In particular, C++ templates are not supported by C#.

0

精彩评论

暂无评论...
验证码 换一张
取 消