tags:

views:

623

answers:

5

I heard somewhere that you can drop down to C++ directly inside C# code. How is this done? Or did I hear wrong?

Note: I do not mean C++ / CLI.

+3  A: 

You heard incorrectly.

Brad Wilson
+8  A: 

You might be thinking of unsafe blocks where you can write code that looks a lot like C++, since you can use pointers.

Mark Cidade
A: 

Why would you need to do that? You can reference native C libraries, but I doubt very much that you can run native code from within managed code.

Mark
don't need to, just wondering if it was possible.
Brian R. Bondy
A: 

You can interact with COM objects very easily from .NET.

Jacob
+2  A: 

You can drop down to Assembly from C, because C is instruction-set-semi-agnostic Assembly.

You can drop down to C from C++, because C++ is C plus some other things that make it divinely ugly or horrifically beautiful, depending on your perspective.

You can't drop down from C# to C++, because they are entirely different things. There is no direct relation between them, aside from the curly-brackets-and-semicolons syntax. C# is not a superset of C++, nor a subset of it, nor a sibling of it (but perhaps a second cousin).

That said, C# provides facilities for interacting with external code at all levels of abstraction, from Platform-Invoke (calling functions written in C) to COM to a wide variety of other kinds. But C# itself is not directly related to these things.

Justice
there is no reason why it wouldn't be possible, but I do understand that it's not implemented.
Brian R. Bondy