Created
August 26, 2023 03:51
-
-
Save liphvf/fee71c577b89ea1e0a6ff44d76f3135f to your computer and use it in GitHub Desktop.
StackVsHeapExemplo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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