Can you write a block of c++ code inside C#?

前端 未结 5 1137
执念已碎
执念已碎 2021-01-20 06:47

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.

5条回答
  •  独厮守ぢ
    2021-01-20 07:11

    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.

提交回复
热议问题