国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

使用C#拷貝String到struct

2024-07-21 02:19:26
字體:
來源:轉載
供稿:網友
  • 網站運營seo文章大全
  • 提供全面的站長運營經驗及seo技術!
  • 使用c#拷貝string到struct

    by dgiljr

    介紹

    本文介紹使用c#拷貝string到struct 。

    代碼

    using system;
    using system.runtime.interopservices;
    using system.text;

    class class1
    {

    [structlayout(layoutkind.sequential, charset=charset.unicode)]
    public struct mystruct
    {
    [marshalas(unmanagedtype.byvaltstr, sizeconst=4)] public string fname;
    [marshalas(unmanagedtype.byvaltstr, sizeconst=4)] public string lname;
    [marshalas(unmanagedtype.byvaltstr, sizeconst=7)] public string phone;
    }

    public static void main()
    {
    string buffer = "abcdefgh2223333";
    intptr pbuf = marshal.stringtobstr(buffer);
    mystruct ms = (mystruct)marshal.ptrtostructure(pbuf,typeof(mystruct));
    console.writeline("fname is: {0}",ms.fname);
    console.writeline("lname is: {0}",ms.lname);
    console.writeline("phone is: {0}",ms.phone);
    }
    }


    from :

    http://www.codeproject.com/csharp/gil_structs.asp





    [email protected]

    http://home.ripway.com/2004-6/124912/
    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 甘孜县| 醴陵市| 甘泉县| 河间市| 彰化县| 镇远县| 怀宁县| 红河县| 图木舒克市| 咸宁市| 达拉特旗| 泸西县| 阜平县| 永春县| 鄂托克旗| 依兰县| 湘阴县| 桦甸市| 临漳县| 德兴市| 靖西县| 巴林左旗| 海晏县| 平舆县| 南郑县| 马鞍山市| 县级市| 榆林市| 甘孜县| 嘉祥县| 阳城县| 河北区| 邵阳县| 通城县| 五家渠市| 邹城市| 眉山市| 安宁市| 黄梅县| 松原市| 滦南县|