Courses /
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.cs
1. Global scoped variables can be accessed inside all methods.
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);
}
}
}
Everything was clear?
Section 6. Chapter 9
Course Content
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.cs
1. Global scoped variables can be accessed inside all methods.
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);
}
}
}
Everything was clear?
Section 6. Chapter 9