C# ^什么意思
System::Int32^ nCSharp = 20;
System::Int32 nNum;
nNum = nCSharp;
这个东西为什么编译不通过
错误 1 error C2440: “=”: 无法从“System::Int32 ^”转换为“int” d:\Projects\ArrStringTest\ArrStringTest.cpp 36 我想用用C#写dll 然后VC调用 可以C#中的方法返回的是 xxxx结构的^类型 我如何把这个变量转换为xxxx类型呢 就如上面的那个例子
顺便问一下 在VC调用C#的DLL数据时 有没有什么好办法可以更方便转换呢 我现在用的是对每个数据结构进行一个一个的定义拷贝函数方法
System::Int32^ nCSharp = 20;
System::Int32 nNum;
nNum = nCSharp;
这个东西为什么编译不通过
错误 1 error C2440: “=”: 无法从“System::Int32 ^”转换为“int” d:\Projects\ArrStringTest\ArrStringTest.cpp 36 我想用用C#写dll 然后VC调用 可以C#中的方法返回的是 xxxx结构的^类型 我如何把这个变量转换为xxxx类型呢 就如上面的那个例子
顺便问一下 在VC调用C#的DLL数据时 有没有什么好办法可以更方便转换呢 我现在用的是对每个数据结构进行一个一个的定义拷贝函数方法
解决方案 »
- sql2000行列动态转置(C#)
- 求C#的最短路径算法(Dijkstra)
- c#winform:开发多语言应用程序---多国语言本地化与设计模式的思考----观察者模式+工厂模式!有请五裤衩以上的掌柜地主们发言
- 高分求分析IP包(最好有源码)
- C# 使用Dictionary<TKey,TValue> 遇到的问题?
- 如何用WCF做网络编程?
- 为何 在一个新线程中更新主Form中的界面元素 引发主Form不可用?高手来看!!!
- Form的哪个属性可以禁止改变窗口大小?
- 新手求组,如何从一堆字符串中截取出数字
- 好麻烦啊!DATAGRID 重载过的 ,有combo 的,但是为什么load后,反应特别慢?
- 关于编码问题
- 光标在指定的位置
看你的代码应该是Manager C++而不是C#
在Manager C++中^是执行托管对象的指针。
例子:
// mcppv2_handle.cpp
// compile with: /clr
ref class MyClass {
public:
MyClass() : i(){}
int i;
void Test() {
i++;
System::Console::WriteLine(i);
}
};int main() {
MyClass ^ p_MyClass = gcnew MyClass;
p_MyClass->Test(); MyClass ^ p_MyClass2;
p_MyClass2 = p_MyClass; p_MyClass = nullptr;
p_MyClass2->Test();
}参考:
http://msdn.microsoft.com/en-us/library/yk97tc08(VS.80).aspx
System::Int32^ nCSharp = 20;
System::Int32 nNum;
nNum = *nCSharp; System::Console::WriteLine(nNum);
System::Console::Read();
不明白你说要copy是什么意思,最好举个例子。
C#
namespace ClassLibrary1
{
public class Class1
{
public static MyData GetObject()
{
return new MyData();
}
} public class MyData
{
public int a = 4;
public string b = "hello"; }
}C++ MyData^ d = ClassLibrary1::Class1::GetObject(); System::Console::WriteLine(d->a);
System::Console::WriteLine(d->b);
System::Console::Read();