--- lang: ja-jp breaks: true --- # C# 8.0 「??=」 null合体演算子 複合代入 2021-04-11 へ~。 > null 合体代入 (??=) > C# 8.0 では、null合体演算子 (??)も複合代入に使えるようになりました(??=)。 > > 例えば以下のような書き方ができます。 > ```csharp= > static void M(string s = null) > { > s ??= "default string"; > Console.WriteLine(s); > } > ``` > 意味としては、if (s == null) s = ...; と同じになります。キャッシュ用途に便利だったりします。 > https://ufcpp.net/study/csharp/sp2_nullable.html#coalescing ###### tags: `C#` `C# 8.0`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up