--- lang: ja-jp breaks: true --- # C# C# 8.0では、`switch` の 式 が使える 2021-08-30 > is、switch の拡張 (型スイッチ) > C# 8.0 では、switch の式版が追加されました。 式なので戻り値が必須です。 > https://ufcpp.net/study/csharp/datatype/typeswitch/?p=5#switch-expressionz ```csharp= private float get_ZoomX(short mode) => mode switch { 0 => m_userWidth / (float)m_marginBounds.Width, 1 => 14.4f, 2 => 0.72f, 3 => 0.01f * m_dpiX, 4 => 0.12f, 5 => 0.01f, 6 => 0.254f, 7 => 0.0254f, 8 => 25.4f, _ => 0f, }; ``` ###### tags: `C#` `C# 8.0` `switch の 式`