您的位置:首页 > 编程语言 > C#

c的结构在c#里的定义方法

2013-06-05 13:38 211 查看
typedef struct{
songinfo  songs[5];
int      foundnum;
}QUERYRESULT;

typedef struct{
int id;
int hits;
char name[80];
float spos[5];
int sposnum;
}songinfo;


c#

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct QueryResult
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public SongInfo[] songs;//检索到的音频信息列表
public int foundnum; //检索到的音频数量
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct SongInfo
{
public int id; //该音频文件对应的id号
public int hits; //待检索音频与该音频对应的冲撞值
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
public string name; //音频对应的文件名
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public float[] spos;//待检索音频数据在该音频中的起始时间
public int sposnum; //待检索音频数据在音频中的位置数量
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: