C#
ToString("d") // 数値
ToString("g") // 文字列
- One Linerで変数に代入
if (function(a,b) is var var1 && var1 != null) {
// var1 do something
}
- 数値文字列のフォーマット
private static readonly Regex numberReg = new(@"\B(?=(\d{3})+(?!\d))", RegexOptions.Compiled);
/// <summary>
/// 数値文字列のフォーマット
/// </summary>
private static string FormatNumberString(string numStr)
{
if (string.IsNullOrEmpty(numStr))
{
return numStr;
}
// 整数部をカンマフォーマット、小数部はそのまま
var splited = numStr.Split(".");
return numberReg.Replace(splited[0], ",") + (splited.Length >= 2 ? ("." + splited[1]) : "");
}
Reference
ASP.net Core at github
.NET Framework source code online at github
.NET Framework source code online at ms ..UI系(System.Windows.Forms. など)はここ
Visual Studio Extensions
- Match Margin
- indent-rainbow