日期:2014-05-18 浏览次数:20427 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="str.aspx.cs" Inherits="str" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <div> 请输入: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="格式化" /></div> </form> </body> </html>
------解决方案--------------------
static void Main(string[] args) { int i = 1; Console.Write(string.Format("{0:00}", i)); }
------解决方案--------------------
这样也可以
int i = 1; string str = i.ToString().PadLeft(2,'0');//01