Joh*_*ell 6 c# c++ windows-runtime
我们有一个带有业务逻辑的WinRT组件,可以在内部按摩C++ unsigned char缓冲区.我们现在想从C#中提供缓冲区byte[].完美的边界会是什么样的,即SomeWinRTFunction下面的函数的签名是什么?
void SomeWinRTFunction(something containing bytes from managed land)
{
IVector<unsigned char> something using the bytes given from managed land;
}
Run Code Online (Sandbox Code Playgroud)
对于搜索引擎来说,这类问题看起来似乎太新了......
在C++部分,该方法应该接受uint8的平台数组(相当于C#字节).
public ref class Class1 sealed
{
public:
Class1();
//readonly array
void TestArray(const Platform::Array<uint8>^ intArray)
{
}
//writeonly array
void TestOutArray(Platform::WriteOnlyArray<uint8>^ intOutArray)
{
}
};
Run Code Online (Sandbox Code Playgroud)
在C#部分传递字节数组:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Byte[] b = new Byte[2];
b[0] = 1;
var c = new Class1();
c.TestArray(b);
c.TestOutArray(b);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6524 次 |
| 最近记录: |