emplooy中有一个私有属性name,方法直接从name的值中得到拼音代码.

解决方案 »

  1.   

    函数原型 BOOL WINAPI GetPinYinLeader(PCHAR pBuf,PCHAR pStr)
      

  2.   

    不难,引用Win32的API用 DllImport
      

  3.   

    http://community.csdn.net/Expert/topic/3073/3073492.xml?temp=.5007898上次回答的。。
    可能实现你这个功能。。
      

  4.   

    这句错了,返回类型是string吧,所以造成无法将类型“bool”隐式转换为“string”
    public  static  extern bool  GetPinYinLeader(string pBuf,string pStr);
      

  5.   

    用SharpDevelop,可以实现VB<->C#的转换
    网址:http://www.sharpdevelop.net/
    下载地址:http://www.sharpdevelop.net/OpenSource/SD/Download/
      

  6.   

    //Private Declare Function GetPinYinLeader Lib "pinyin.dll" (ByVal pBuf As String, ByVal pString As String) As Long[DllImport("Pinyin.dll" , EntryPoint="GetPinYinLeader", CharSet=CharSet.Auto)]
    public  static  extern long  GetPinYinLeader(string pBuf,string pStr);public string GetNamePY()
    {
    string strBuf;
             long l;
    if (name == "") 
    return "";
    else
             {
                      l= GetPinYinLeader( strBuf ,name);
                      strBuf=l.ToString();
                      return strBuf;
              }
    }
      

  7.   

            ClsPatient patient = new ClsPatient();
    patient.ID ="001";
    patient.Name ="刘海潮";
    patient.Sex =1;
    patient.Birthday =new DateTime(1972,06,06);
    byte age=patient.GetAge();
    string pycode=patient.GetNamePY();
    MessageBox.Show(patient.ID.ToString() + "   " +patient.Name.ToString() + "  " +age.ToString() + " " +
    pycode.ToString()+ "  " + patient.GetSexString());
    返回的拼音代码怎么是一串数字呀,
      

  8.   

    这就是你下面的函数的问题啦
    Private Declare Function GetPinYinLeader Lib "pinyin.dll" (ByVal pBuf As String, 
    ByVal pString As String) As Long
      

  9.   

    函数原型
    //获得拼音首字母
        //参数依次为: 拼音缓存区,要转换的字符
        BOOL WINAPI GetPinYinLeader(PCHAR pBuf,PCHAR pStr)
      

  10.   

    studio .net 2003提供了转换工具
      

  11.   

    如果方便,把dll文件发给我试试[email protected],就不信搞不定了。
      

  12.   

    [DllImport("Pinyin.dll" , EntryPoint="GetPinYinLeader", CharSet=CharSet.Auto)]
            public  static  extern long  GetPinYinLeader(string pBuf,string pStr);
    public string GetNamePY()
    {
    string strBuf="" ;
    long l=1;
    if (name == "") 
    return "";
    else
    l = GetPinYinLeader(strBuf ,name);
    //strBuf=l.ToString();
    strBuf=strBuf.Trim() ;
    return strBuf; }
    现在返回的是name的值,如果name="刘海"
    那么strbuf也是,strBuf="刘海",好像这个函数没有执行.
      

  13.   

    收到了你的消息,去下载了试试,也没试出来。跟你的结果一样,郁闷ing...
      

  14.   

    to zmgcj(真的名贵):这个DLL很不错,体积小,查的字也很全,我也看了一些C#下的,有些字查不出来,要不就用数据库表查询,很不方便,以前在VB6下用的很好,可惜.
      

  15.   

    VB.NET里面都可以实现,C#没有道理不行的,不知道哪里少了根筋,请高人指导一下吧
      

  16.   

    Download Software:
    http://www.sharpdevelop.net/OpenSource/SD/Download
      

  17.   

    //Private Declare Function GetPinYinLeader Lib "pinyin.dll" (ByVal pBuf As String, ByVal pString As String) As Long[DllImport("Pinyin.dll" , EntryPoint="GetPinYinLeader", CharSet=CharSet.Auto)]
    public  static  extern long  GetPinYinLeader(string pBuf,string pStr);public string GetNamePY()
    {
    string strBuf;
             long l;
    if (name == "") 
    return "";
    else
             {
                      l= GetPinYinLeader( strBuf ,name);
                      strBuf=l.ToString();
                      return strBuf;
              }
    }