asp.net ToString¸ñʽ´óÈ«
תÔØÓÚ£ºhttp://hi.baidu.com/juzi119/blog/item/d4bf9a4b7cea7df583025c9e.html
C »õ±Ò 2.5.ToString("C") £¤2.50
D Ê®½øÖÆÊý 25.ToString("D5") 00025
E ¿ÆѧÐÍ 25000.ToString("E") 2.500000E+005
F ¹Ì¶¨µã 25.ToString("F2") 25.00
G ³£¹æ 2.5.ToString("G") 2.5
N Êý×Ö 2500000.ToString("N") 2,500,000.00
X Ê®Áù½øÖÆ 255.ToString("X")
FF
formatCode ÊÇ¿ÉÑ¡µÄ¸ñʽ»¯´úÂë×Ö·û´®¡££¨ÏêϸÄÚÈÝÇëËÑË÷“¸ñʽ»¯×Ö·û´®”²é¿´£©
±ØÐëÓÓ{”ºÍ“}”½«¸ñʽÓëÆäËû×Ö·û·Ö¿ª¡£Èç¹ûÇ¡ºÃÔÚ¸ñʽÖÐҲҪʹÓôóÀ¨ºÅ£¬¿ÉÒÔÓÃÁ¬ÐøµÄÁ½¸ö´óÀ¨ºÅ±íʾһ¸ö´óÀ¨ºÅ£¬¼´£º “{{”»òÕß“}}”¡£
³£Óøñʽ¾ÙÀý£º
£¨1£© int i=12345;
this.textBox1.Text=i.ToString();
//½á¹û 12345£¨thisÖ¸µ±Ç°¶ÔÏ󣬻ò½Ðµ±Ç°ÀàµÄʵÀý£©
this.textBox2.Text=i.ToString("d8");
//½á¹û 00012345
£¨2£© int i=123;
double j=123.45;
string s1=string.Format("the value is {0,7:d}",i);
string s2=string.Format("the value is {0,7:f3}",j);
this.textBox1.Text=s1 ;
//½á¹û the value is 123
this.textBox2.Text=s2;
//½á¹û the value is 123.450
£¨3£©double i=12345.6789;
this.textBox1.Text=i.ToString("f2"); //½á¹û 12345.68
this.textBox2.Text=i.ToString("f6");
//½á¹û 12345.678900
£¨4£©double i=12345.6789;
this.textBox1.Text=i.ToString("n"); //½á¹û 12,345.68
this.textBox2.Text=i.ToString(“n4”); //½á¹û 12,345.6789
£¨5£©double i=0.126;
string s=string.Format("the value is {0:p}",i);
this.textBox1.Text=i.ToString("p"); //½á¹û 12.6%
this.textBox2.Text=s; //½á¹û the value is 12.6%
£¨6£© DateTime dt =new DateTime(2003,5,25);
this.textBox1.Text=dt.ToString("yy.M.d");
//½á¹û 03.5.25
this.textBox2.Text=dt.ToString(“yyyyÄêMÔ”);
//½á¹û 2003Äê5ÔÂ
Convert.ToDateTime("2005/12/22 22:22:22").ToString("yyyy/MM/dd HH:mm:ss")
"2005/12/22 22:22:22"
£¨7£© int i=123;
double j=123.45;
string s=string.Format("i:{0,-7},j:{1,7}",i,j);
//-7±íʾ×ó¶ÔÆ룬ռ7λ
this.textBox1.Text=s ;
//½á¹ûi:123 ,j: 123.45
DateTime.ToString()Ó÷¨Ïê½â
ÎÒÃǾ³£»áÓöµ½¶Ôʱ¼ä½øÐÐת»»,´ïµ½
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
ÍøÒ³ÖÐÓÃTextBoxÈÃÓû§ÊäÈëÎı¾£¬È»ºó´æÈëÊý¾Ý¿â£¬ÔÙ´ÓÊý¾Ý¿âÖжÁ³öÏÔʾÔÚÒ³ÃæÉÏ¡£³£³£ÕâÑù×ö»áÓöµ½²»ÉÙÎÊÌ⣬ÒòΪTextBoxʵ¼ÊÉÏÊÇÒ»¸öWindows×é¼þ£¬ºÍÍøÒ³ÏÔʾ±ê¼ÇÈ磺<p>,<td>,<div>µÈ£¬¶Ô×Ö·ûµÄ½âÎö·½·¨ÊDz»Í¬µÄ¡£±ÈÈçÇ°ÕߵĻ»Ðбê¼ÇΪ“\r\n”£¬¶øºóÕßΪ“<br>”¡£Õ ......
1 ʾÀýxmlÎļþ model.xml
<?xml version="1.0" encoding="utf-8" ?>
<DrRoot>
<SiteName>xml²Ù×÷ʾÀý</SiteName>
<SiteUrl>www.abc.com.cn</SiteUrl>
.net¿ªÔ´ÂÛ̳
<SiteKeyWord>xml²Ù×÷ʾÀý</SiteKeyWord>
<FileType>gif|jpg| ......
//ÏÈ¿´¿´ASP.NETÒ³ÃæˢеÄʵÏÖ·½·¨£º
//µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); }
//µÚ¶þ£º
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript> ......
ASP.NETÒ³Ãæˢз½·¨×ܽá
ÏÈ¿´¿´ASP.NETÒ³ÃæˢеÄʵÏÖ·½·¨£º
µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } µÚ¶þ£º
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script langua ......