如:
string s="abcd";
char cc=s[0];
int ii=(int)cc;//int ii=(int)'a';
就可以了

解决方案 »

  1.   

    // 给你个函数:
    public string CharToIntStr(string str)
    {
         string result = "";
         foreach(char ch in str) 
         {
    if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) 
                  result += (int)ch;
    else result += ch;
          }
          return result;
    }// 使用实例:
    private void button1_Click_1(object sender, System.EventArgs e)
    {
        string str = "AbcdEfg789";
        MessageBox.Show(CharToIntStr(str));
    }
      

  2.   

    byte[] arr = System.Text.ASCIIEncoding.ASCII.GetBytes(txtUserName.Text);
    string str1 = arr[0].ToString();
    txtPassword.Text=str1;