34 lines
734 B
C#
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();
|