Зміст курсу
C# Basics
C# Basics
Practicing Scopes
There are three variables in the following code. Fill in the blanks with variable names such that the code compiles successfully:
main
using System; namespace ConsoleApp { class Program { static int var1 = 10; static void Main(string[] args) { int var2 = 11; if(var1 > 5) { Console.WriteLine(___); } else { int var3 = 12; Console.WriteLine(___); } } static void output() { Console.WriteLine(___); } } }
- Global scoped variables can be accessed inside all methods.
main
using System; namespace ConsoleApp { class Program { static int var1 = 10; static void Main(string[] args) { int var2 = 11; if(var1 > 5) { Console.WriteLine(var2); } else { int var3 = 12; Console.WriteLine(var3); } } static void output() { Console.WriteLine(var1); } } }
Дякуємо за ваш відгук!