Mixing CS and MC++?

  • Thread starter Thread starter Daniel =?iso-8859-1?Q?Lidstr=F6m?=
  • Start date Start date
D

Daniel =?iso-8859-1?Q?Lidstr=F6m?=

Hello,

is it possible to ``use CS to code a class, and (M)C++ for the logic''?
Sorry if this sounds vague, I'm not really sure myself what it means. Does
anyone have any ideas?
 
Daniel,

You can use VB, C# or C++ (managed) to create a batch of class libraries
(DLL's), and then these can be referenced in one solution...

A project can only be coded in one format, but a solution can contain many
projects, which can be a mixture.

Does that make sense?

Dan
 
Daniel said:
Hello,

is it possible to ``use CS to code a class, and (M)C++ for the
logic''? Sorry if this sounds vague, I'm not really sure myself what
it means. Does anyone have any ideas?

Is it possible to declare a class in C# and implement the methods of the
class in MC++? No. Not directly anyway.

Is it possible to implement a class in C# and use it from MC++? Yes.

Is it possible to implement a class in MC++ and use it from C#? Yes.

Is it possible to call functions written in C++ from a class written in C#?
Yes.

Hopefully one of those was the question you were trying to ask...

-cd
 
The *only* real point in using managed c++ is either
1) to migrate legacy code to managed code
2) for managed code to interact with unmanaged code with the best possible
performance.

It sounds like your aim is (2).
Basically, if you need to use unamanaged code in your managed application,
for reasons of security and/or speed, then write that unmanaged code in
unmanaged C/C++, and *then*, after having tested it, write as thin a wrapper
as possible round it in managed c++. This should be minimalistic, non-logic
containing code, the minimum that is required to interface between C# and
the unmanaged functions. You can have a DLL that has some .cpp /.c files
compiled with /clr, and some .cpp files that are compiled without /clr. The
ones compiled without /clr have no concept of what managed code is, yet as
far as the C# side is concerned, it's a normal, managed, .NET class library.
No PInvoke or COM required.
 
Back
Top