Challenge: Scopes
There are three variables in the following code. Fill in the blanks with variable names such that the code compiles successfully:
main.cs
1234567891011121314151617181920212223242526using 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.cs
123456789101112131415161718192021222324252627282930using 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); } } }
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 6. Kapitel 9
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 1.59
Challenge: Scopes
Svep för att visa menyn
There are three variables in the following code. Fill in the blanks with variable names such that the code compiles successfully:
main.cs
1234567891011121314151617181920212223242526using 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.cs
123456789101112131415161718192021222324252627282930using 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); } } }
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 6. Kapitel 9