Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Desafio: Escopos | Métodos
Quizzes & Challenges
Quizzes
Challenges
/
Fundamentos de C#

bookDesafio: Escopos

There are three variables in the following code. Fill in the blanks with variable names such that the code compiles successfully:

main.cs

main.cs

copy
1234567891011121314151617181920212223242526
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.cs

main.cs

copy
123456789101112131415161718192021222324252627282930
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); } } }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 6. Capítulo 9

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

What are the variable names that should be used in the code?

Can you provide an example of how to fill in the blanks?

Can you explain why global scoped variables can be accessed inside all methods?

bookDesafio: Escopos

Deslize para mostrar o menu

There are three variables in the following code. Fill in the blanks with variable names such that the code compiles successfully:

main.cs

main.cs

copy
1234567891011121314151617181920212223242526
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.cs

main.cs

copy
123456789101112131415161718192021222324252627282930
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); } } }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 6. Capítulo 9
some-alt