views:

174

answers:

2

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 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

A: 

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

Stephen Cleary
Well, c# has generics but they aren't the same... so no way to use c# syntax to create something like a game (yea I know XNA, but I would like to write something totally detached from CLR, that uses directx or opengl)
Fire-Dragon-DoL
+3  A: 

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.

JaredPar