Is there a simpler way to do this if statement in C#

后端 未结 7 1426
说谎
说谎 2021-01-21 03:05

I have the following:

if (model.PartitionKey.Substring(2, 2) == \"05\" || 
    model.PartitionKey.Substring(2, 2) == \"06\")

I have more like t

7条回答
  •  时光说笑
    2021-01-21 03:38

    if (new []{"05", "06"}.Contains(model.PartitionKey.Substring(2, 2))

    the syntax might be far off, corrections are welcome :)

    Edit: new []

提交回复
热议问题