24
1
using System;
2
3
var product = new Product()
4
{
5
Name = "product",
6
Weight = 40
7
};
8
9
var deliveryPrice = product.Weight switch
10
{
11
< 30 => 0,
12
>= 30 and < 50 => 20,
13
>= 50 => 100
14
};
15
16
Console.WriteLine(deliveryPrice);
17
18
19
class Product
20
{
21
public string Name { get; set; }
22
23
public decimal Weight { get; set; }
24
}
Cached Result