Local 測試完畢後,接下來就要發佈到 Server 上。
專按按右鍵,選擇 Publish,選擇其中的 IIS, FTP, etc
老是記不住,只能寫下來。
decimal d = 0;
string s = "123.456";
if (decimal.TryParse(s, out d))
MessageBox.Show(d.ToString("N1"));
else
MessageBox.Show(s);
/// <summary>
/// MROUND 函數為:傳回四捨五入為所需倍數的數字。EX.MROUND(7,5)=>5 MROUND(8,5)=>10
/// </summary>
/// <param name="number">原始數值</param>
/// <param name="multiple">倍數因子 (計算0.5的倍數就傳0.5)</param>
/// <returns>計算後的結果,效果等同 Excel MROUND 公式</returns>
public static decimal GetMROUND(decimal number, double multiple)
{
return Math.Round(number / (decimal)multiple, MidpointRounding.AwayFromZero) * (decimal)multiple;
}
為了避免某段程序執行時無回應,想用另一個 Thread 來處理並回寫資料。(通常是寫入某個元件,例如 Label 或 TextBox,同理讀取資料也是)
... 因為上面那三行程式都在同一個 UI thread 上面, 而 Windows Form 會在 UI thread 上的指令執行完畢並且返回之後, 才會觸發它的 Paint 事件。同樣的程式, 如果 ... 在 Console 程式中這個問題就不會發生, 因為 Console 程式沒有像 Windows Form 那種 Paint 事件。
private async void btnTest_Click(object sender, EventArgs e)
{
//
// do something...
//
await doSomethingAsync();
}
private async Task doSomethingAsync()
{
//
// do something...
//
await Task.Delay(1000); // 暫停一下,看效果用
}