2010-08-21 4 views
1

Comment recevoir des chaînes à partir de C# dans une DLL .net basée sur Visual-C++?Comment recevoir des chaînes de C# dans une DLL .net basée sur Visual-C++?

En C++ (en utilisant clr) J'ai ce code:

#include "stdafx.h" 
##include <Windows.h> 
#include <string> 
#include <windows.h> 

namespace NSST 
{ 
    public ref class Wrapper 
    { 
public: 
    Wrapper() {} 
    static void init_1(std::string a, std::string b){} 
    static void init_2(){} 
    }; 
}; 

Mais en .net C# Je ne vois qu'une seule fonction init_2. Comment afficher init_1 dans .net?

Répondre

3

Vous ne pouvez pas utiliser std :: string, vous devez utiliser System :: String ^:

static void init_1(System::String^ a, System::String^ b); 
+0

et comment transformer System :: String^un dans std :: string a? c'est possible? – Rella

+0

Bien sûr, regardez ici: http://buffered.io/2007/03/02/net-systemstring-to-ansi-char/ –

+0

Lien mis à jour pour cet article: http://buffered.io/posts/ net-systemstring-to-ansi-char/(serait bien si les anciens commentaires étaient modifiables aussi). –

Questions connexes