[csharp]C# 最近出現的 ? ! 是做什麼用的?

  • 60
  • 0
  • 2024-01-08

C# 最近出現的 ? ! 是做什麼用的?

最近終於找到一個圖快速介紹這些?!是做什麼用的。

主要是用以解決 null 相關的問題的語法糖

https://twitter.com/mwaseemzakir/status/1647856976477450240/photo/1

Ternary Operator (?:)
Null Forgiving Operator (!.)
Null Conditional Operator (?.)
Null Coalescing Operator (??)
Null Coalescing Assignment Operator (??=)

 

 

 

 

分享