ms_learn_csharp/027_create_methods/methods/Program.cs
2024-08-10 21:03:39 -04:00

34 lines
734 B
C#

Console.WriteLine("Before calling a method");
SayHello();
Console.WriteLine("After calling a method");
void SayHello() {
Console.WriteLine("Hello World!");
}
void DisplayRandomNumbers01() {
Random random = new Random();
}
void DisplayRandomNumbers02() {
Random random = new Random();
for (int i = 0; i < 5; i++) {
Console.Write($"{random.Next(1, 100)} ");
}
Console.WriteLine();
}
void DisplayRandomNumbers03() {
Random random = new Random();
for (int i = 0; i < 5; i++) {
Console.Write($"{random.Next(1, 100)} ");
}
Console.WriteLine();
}
Console.WriteLine("\nGenerating random numbers:");
DisplayRandomNumbers01();
DisplayRandomNumbers02();
DisplayRandomNumbers03();