.NET還滿方便的
有一個很簡單的方式直接就可以幫忙算
只是只有四種進制的轉換...
其他進制應該也不難查到資訊....
protected void Button2_Click(object sender, EventArgs e)
{
string num = ConvertString("100010111111011", 2, 8);
Response.Write(num);
}
//ConvertString(值,來源進制,目的進制)只能輸入=>2、8、10、16進制
public string ConvertString(string value, int from, int to)
{
int intValue = Convert.ToInt32(value, from);
return Convert.ToString(intValue, to);
}
也有其他人有不一樣的方式
http://www.dotblogs.com.tw/jaigi/archive/2010/02/01/13428.aspx
http://www.ychlccsc.edu.hk/subject/maths/pack0203.html
http://blog.miniasp.com/post/2008/03/14/14/Convert-different-base-number-in-CSharp.aspx
文章標籤
全站熱搜
