Skip to content

Instantly share code, notes, and snippets.

@liphvf
Created August 26, 2023 03:51
Show Gist options
  • Save liphvf/fee71c577b89ea1e0a6ff44d76f3135f to your computer and use it in GitHub Desktop.
Save liphvf/fee71c577b89ea1e0a6ff44d76f3135f to your computer and use it in GitHub Desktop.
StackVsHeapExemplo.cs
public class Program
{
const int ADULT_AGE = 18;
private static void Main(string[] args)
{
var myBirthDay = new DateOnly(1991, 3, 13);
var iGrowUp = isAdult(myBirthDay);
if (iGrowUp)
Console.WriteLine("I'm an adult");
else
Console.WriteLine("I'm not an adult");
}
public static bool isAdult(DateOnly dateOfBirth)
{
var actualDate = DateOnly.FromDateTime(DateTime.Today);
return (actualDate.Year - dateOfBirth.Year) > ADULT_AGE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment