C++/C#结构体转化-传string给C++
此例是把C#结构传给C++
C++:
typedef struct VidyoClientInEventGroupChat_
{
/*! Message (contents) to be sent to all remote participants */
char message[MAX_CHAT_MESSAGE_LEN];
} VidyoClientInEventGroupChat;
C#:
[StructLayout(LayoutKind.Sequential)]
public struct VidyoClientInEventGroupChat
{
unsafe fixed byte message[MAX_CHAT_MESSAGE_LEN];
public unsafe bool SetMessage(string message)
{
byte[] bytes = UnicodeStringToUtf8Array(message);
if (bytes.Length > MAX_CHAT_MESSAGE_LEN)
{
return false;
}
fixed (VidyoClientInEventGroupChat* p = &this)
for (int i = 0; i < bytes.Length; i++)
{
p->message[i] = bytes[i];
}
return true;
}
};
C++/C#结构体转化-传string给C++的更多相关文章
- GO学习-(38) Go语言结构体转map[string]interface{}的若干方法
结构体转map[string]interface{}的若干方法 本文介绍了Go语言中将结构体转成map[string]interface{}时你需要了解的"坑",也有你需要知道的若 ...
- C#调用C++ dll时,结构体引用传参的方法
写了一个C++的LogLog Logit 四参数等算法的接口dll,给C#调用,但是发现传参有问题 如 extern "C" _declspec(dllexport) bool ...
- C++/C#结构体转化-二维数组-bytes To Strings
C++结构体 typedef struct VidyoClientRequestGetWindowsAndDesktops_ { /*! The number of application windo ...
- C++的结构体指针传参
typedef struct node{int n;node *left;}*tnode; 传参的时候注意用** void init(node **nn);int main(){tnode nna;i ...
- C++/C#结构体转化-二维数组
String To bytes typedef struct VidyoClientInEventGroupChat_ { /*! Message (contents) to be sent to a ...
- 转载 C#结构体(struct)和类(class)的区别
转载原地址: http://dotnet.9sssd.com/csbase/art/8 C#结构体和类的区别问题:在C#编程语言中,类属于引用类型的数据类型,结构体属于值类型的数据类型,这两种数据类型 ...
- C++学习 3 结构体
结构体基本概念: 结构体属于用户自定义的数据类型,允许用户存储不同的数据类型: 结构体定义和使用: 语法:struct 结构体名 { 结构体成员列表 }: 通过结构体创建变量名的方式有三种: ...
- golang中如何将json文件解析成结构体
package tool import ( "bufio" "encoding/json" "fmt" "os" ) t ...
- Go 结构体方法
#### Go 结构体方法本来今天有些事情忙的不准备更新内容了,后来提前完成了, 所以还是要更新了; 毕竟坚持本就是一件不容易的事情!加油,相信不管是大家还是我,都有一些事情想要做,那就坚持吧,剩下的 ...
随机推荐
- Hibernate 、多表关联映射 - 多对多关系映射(many-to-many)
hibernate.cfg.xml: <hibernate-configuration> <session-factory name="sessionFactory&quo ...
- Linux学习十八之、善用判断式
原文地址:http://vbird.dic.ksu.edu.tw/linux_basic/0340bashshell-scripts_3.php 善用判断式 在第十一章中,我们提到过 $? 这个变量所 ...
- rem布局
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JavaWeb学习—Servlet
1.什么是Servlet Servlet是一个继承HttpServlet类的Java类 Servlet必须部署在web服务器端,用来处理客户端的请求 2.Servlet运行过程 Web Client ...
- uva 193 Graph Coloring(图染色 dfs回溯)
Description You are to write a program that tries to find an optimal coloring for a given graph. Col ...
- ios 后台模式
1.在后台可以继续播放音频 To play sound in the background, make sure to add the following to the Info.plist file ...
- xCode6制作动态及静态Framework(转)
原文:http://years.im/Home/Article/detail/id/52.html 相关推荐:http://www.cocoachina.com/ios/20150127/11022. ...
- html系列教程--embed fieldset legend figure figurecaption
<embed> 标签:定义嵌入的内容 <embed src="" type="" /> embed属性: 1.src:嵌入内容地址 2. ...
- bootstrap注意事项(七)图片
在本章中,我们将学习 Bootstrap 对图片的支持.Bootstrap 提供了三个可对图片应用简单样式的 class: .img-rounded:添加 border-radius:6px 来获得图 ...
- 创建基于maven的项目模版
我们在实际工作中 ,有些项目的架构是相似的,例如基于 restful的接口项目,如果每次都重新搭建一套架构或者通过拷贝建立一个项目难免有些得不偿失,这里我们可以用maven的archtype建立项目模 ...