/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/Boolean/Overview/csharp/operations2.cs
24 строки
759 B
Genevieve Warren
Add remarks for core types (#38970)
05 янв 2024, 22:14
Не верифицирован
05 янв 2024, 22:14
71d1377
Код
Авторство
О чём код?
// <Snippet13> using System; public class Example6 { public static void Main() { bool[] hasServiceCharges = { true, false }; Decimal subtotal = 120.62m; Decimal shippingCharge = 2.50m; Decimal serviceCharge = 5.00m; foreach (var hasServiceCharge in hasServiceCharges) { Decimal total = subtotal + shippingCharge + (hasServiceCharge ? serviceCharge : 0); Console.WriteLine("hasServiceCharge = {1}: The total is {0:C2}.", total, hasServiceCharge); } } } // The example displays output like the following: // hasServiceCharge = True: The total is $128.12. // hasServiceCharge = False: The total is $123.12. // </Snippet13>