BasicKnowledgeCSharp/LessonsAndTasks/Lesson 42 - Оператор условного NULL/Program.cs
Dvurechensky 058c8f2679 1.0
Main
2024-10-05 09:59:53 +03:00

23 lines
507 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Linq;
/*
* Оператор условного NULL ?.
*/
class Program
{
static int[] GetArray()
{
int[] myArray = null;
return myArray;
}
static void Main()
{
int[] myArray = GetArray();
// ?. - проверяет равна ли сумма null или не равна
// ?? - оператор объединения с null
Console.WriteLine(myArray?.Sum() ?? -1);
Console.ReadKey();
}
}