如何将C ++ 2d char数组转换为C#字符串? [英] How to convert a C++ 2d char array into C# string?

查看:123
本文介绍了如何将C ++ 2d char数组转换为C#字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从C ++返回一个char 2d数组。我把它转换成了一个dll并做了所有包装类的东西,所有东西都准备好了。但是我如何通过C#数组获取返回的2D char数组中的值?我怎样才能访问它们?我需要获取2D char数组中的值并将它们打印在C#标签中。请帮助

解决方案

您需要这些步骤。



1.从C#调用C ++获取大小缓冲区(或调用次数)

2.在C#中准备足够的byte []
3.调用C ++填充缓冲区

4.使用C#中的stringbuilder转换byte []


创建一个长字符串并用\ n分隔所有数组字符串并将它们拆分为C#

I am returning a char 2d array from a C++. I converted this into a dll and did all the wrapper class things and everything is prepared.But how can I get the values in the returned 2D char array through C# array? How can I access them? I need to get the values in the 2D char array and print them in C# labels. Please help

解决方案

you need these steps.

1. call from C# to C++ get the size of the buffer (or count of calls)
2. prepare enough byte[] in C#
3. call the C++ to fill the buffer
4. convert the byte[] with stringbuilder in C#

make a "long string" and separate all your array strings with "\n" and split them in C#


这篇关于如何将C ++ 2d char数组转换为C#字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆