首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

进来帮忙解释段代码!多谢啊

2012-01-10 
进来帮忙解释段代码!!谢谢啊!public static string ConvertHexToString(string source){byte[] oribyte

进来帮忙解释段代码!!谢谢啊!
public static string ConvertHexToString(string source)
  {
  byte[] oribyte = new byte[source.Length/2];
  for(int i=0;i<source.Length;i+=2)
  {
  string str = Convert.ToInt32(source.Substring(i,2),16).ToString();
  oribyte[i/2] = Convert.ToByte(source.Substring(i,2),16);
  }
  return System.Text.Encoding.Default.GetString(oribyte);
  }

这段代码,关键的地方,后面帮注上注释。。。谢谢。。


[解决办法]

C# code
 protected void GridViewRelation_RowCommand(object sender, GridViewCommandEventArgs e)    {        CostManagement Cost = new CostManagement();        if (e.CommandName.ToUpper() == "HISTORYRECORD")        {             int i = Convert.ToInt32(e.CommandArgument);             string cardId = GridViewRelation.Rows[i].Cells[5].Text;             string carno = GridViewRelation.Rows[i].Cells[4].Text;            string url = "FrmAtrriHistory.aspx?cardId=" + cardId + "&carno=" + carno;            string ClientScript = "window.showModalDialog('" + url + "','history','dialogWidth:800px;dialogHeight:600px;dialogLeft:200px;dialogTop:200px;center:yes; help:yes;resizable:yes;status:yes')";            Page.RegisterStartupScript("pringGP", "<script>" + ClientScript + "</script>");        }    } CostManagement();        if (e.CommandName.ToUpper() == "HISTORYRECORD")        {             int i = Convert.ToInt32(e.CommandArgument);             string cardId = GridViewRelation.Rows[i].Cells[5].Text;             string carno = GridViewRelation.Rows[i].Cells[4].Text;            string url = "FrmAtrriHistory.aspx?cardId=" + cardId + "&carno=" + carno;            string ClientScript = "window.showModalDialog('" + url + "','history','dialogWidth:800px;dialogHeight:600px;dialogLeft:200px;dialogTop:200px;center:yes; help:yes;resizable:yes;status:yes')";            Page.RegisterStartupScript("pringGP", "<script>" + ClientScript + "</script>");        }    }
[解决办法]
举个例子来说:
我爱你
使用系统默认的编码格式(936)编码后的16进制串为:
CED2B0AEC4E3
用这个字符串(CED2B0AEC4E3)调用你的函数,将返回“我爱你”这个字符。

[解决办法]
学习。
[解决办法]
study..

热点排行