ms_learn_csharp/027_create_methods/methods/Program.cs

34 lines
734 B
C#
Raw Permalink Normal View History

2024-08-10 21:03:39 -04:00
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();