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

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; //待检索音频数据在音频中的位置数量
    }

 

posted @ 2013-06-05 13:38  simadi  阅读(441)  评论(0编辑  收藏  举报