using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class strChange : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//设置货币小数部分的数值
showValue.InnerHtml = GetNumberFormat("134.12554", );
//格式化数据为货币格式
showValue.InnerHtml += "<br />" + GetFormatNumber("134.12554");
//进制转换
showValue.InnerHtml += "<br />十转二:";
showValue.InnerHtml += Convert.ToString(, );
showValue.InnerHtml += "<br />十转八:";
showValue.InnerHtml += Convert.ToString(, );
showValue.InnerHtml += "<br />十转十六:";
showValue.InnerHtml += Convert.ToString(, );
showValue.InnerHtml += "<br />二转八:";
showValue.InnerHtml += Convert.ToString(Convert.ToInt64("", ), );
showValue.InnerHtml += "<br />二转十:";
showValue.InnerHtml += Convert.ToInt64("", ).ToString();
showValue.InnerHtml += "<br />二转十六:";
showValue.InnerHtml += Convert.ToString(Convert.ToInt64("", ), );
showValue.InnerHtml += "<br />八转二:";
showValue.InnerHtml += Convert.ToString(Convert.ToInt64("", ), );
showValue.InnerHtml += "<br />八转十:";
showValue.InnerHtml += Convert.ToInt64("", ).ToString();
showValue.InnerHtml += "<br />八转十六:";
showValue.InnerHtml += Convert.ToString(Convert.ToInt64("", ), );
showValue.InnerHtml += "<br />十六转二:";
showValue.InnerHtml += Convert.ToString(Convert.ToInt64("a", ), );
showValue.InnerHtml += "<br />十六转十:";
showValue.InnerHtml += Convert.ToString(Convert.ToInt64("a", ), );
showValue.InnerHtml += Convert.ToUInt64("a", ).ToString();
//确定弹窗
Button1.Attributes\["OnClick"\] = "return confirm('你确定么?')";
}
private string GetNumberFormat(string str,int deci)
{
double value;
string returnVal = "";
if (double.TryParse(str, out value))
{
NumberFormatInfo NFI = new CultureInfo("zh-CN", false).NumberFormat;
NFI.CurrencyDecimalDigits = deci;
returnVal = value.ToString("C", NFI);
}
else
{
returnVal = "数值不正确~!";
}
return returnVal;
}
private string GetFormatNumber(string str)
{
double value;
string returnVal = "";
if (double.TryParse(str, out value))
{
NumberFormatInfo NFI = new CultureInfo("zh-CN", false).NumberFormat;
NFI.CurrencyGroupSeparator = ","; //设置货币中对小数点左边的数字分组的字符串
returnVal = value.ToString("C", NFI);
}
else
{
returnVal = "数值不正确~!";
}
return returnVal;
}
protected void Button1\_Click(object sender, EventArgs e)
{
showValue.InnerHtml += "<br /> 您点击了确定!";
}
}
交流群:225443677
手机扫一扫
移动阅读更方便
你可能感兴趣的文章