1.補0
String.Format("{0:0000}", 157); // 輸出 0157
2.前後補0
String.Format("{0:0000.0000}", 157.42); // 輸出 0157.4200
3.每3位加逗號
(String.Format("{0:0,0}", 38560); // 輸出 38,560
4.格式化電話號碼
(String.Format("{0:(###) ###-####}", 8005551212); // 輸出 (800) 555-1212
webBrowser1.Navigate("http://www.roomi.com.tw/"); private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { // 使用 WebBrowser.DocumentStream 取得網頁內容 // 使用 StreamReader 讀入資料流,設定編碼為 Encoding.Default System.IO.StreamReader reader = new System.IO.StreamReader(webBrowser1.DocumentStream, System.Text.Encoding.Default); string gethtml = reader.ReadToEnd(); ... }
private void webBrowser5_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser5.ReadyState < WebBrowserReadyState.Complete) return; HtmlElement btnSubmit = webBrowser5.Document.All["btsubmit"]; HtmlElement Date_Year = webBrowser5.Document.All["Date_Year"]; HtmlElement Date_Month = webBrowser5.Document.All["Date_Month"]; HtmlElement Date_Day = webBrowser5.Document.All["Date_Day"]; HtmlElement mycontent = webBrowser5.Document.All["mycontent"]; Date_Year.SetAttribute("value", DateTime.Now.Year.ToString()); Date_Month.SetAttribute("value", DateTime.Now.Month.ToString().PadLeft(2, '0')); Date_Day.SetAttribute("value", DateTime.Now.Day.ToString().PadLeft(2, '0')); mycontent.SetAttribute("value", tmp); btnSubmit.InvokeMember("click"); }