using System;
class Program
{
static void Main(string[] args)
{
int? nullableValue = 42;
Console.WriteLine($"Nullable com valor: {nullableValue.HasValue}");
if (nullableValue.HasValue)
Console.WriteLine($"Valor do Nullable: {nullableValue.Value}");
int? nullableEmpty = null;
Console.WriteLine($"Nullable sem valor: {nullableEmpty.HasValue}");
int defaultValue = 0;
int valueOrDefault = nullableEmpty ?? defaultValue;
Console.WriteLine($"Valor padrao: {valueOrDefault}");
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: