Convert time unit switch statement to switch expression
This commit is contained in:
parent
cc0eba7042
commit
378b6a5e65
1 changed files with 8 additions and 17 deletions
|
@ -49,24 +49,15 @@ namespace BlazorApp.Data
|
|||
continue;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
timeSpan += c switch
|
||||
{
|
||||
case 'W':
|
||||
timeSpan += TimeSpan.FromDays(value * 7);
|
||||
break;
|
||||
case 'D':
|
||||
timeSpan += TimeSpan.FromDays(value);
|
||||
break;
|
||||
case 'H':
|
||||
timeSpan += TimeSpan.FromHours(value);
|
||||
break;
|
||||
case 'M':
|
||||
timeSpan += TimeSpan.FromMinutes(value);
|
||||
break;
|
||||
case 'S':
|
||||
timeSpan += TimeSpan.FromSeconds(value);
|
||||
break;
|
||||
}
|
||||
'W' => TimeSpan.FromDays(value * 7),
|
||||
'D' => TimeSpan.FromDays(value),
|
||||
'H' => TimeSpan.FromHours(value),
|
||||
'M' => TimeSpan.FromMinutes(value),
|
||||
'S' => TimeSpan.FromSeconds(value),
|
||||
_ => throw new ArgumentOutOfRangeException($"Invalid time unit {c}")
|
||||
};
|
||||
|
||||
value = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue