Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Practicing Scopes | Methods
course content

Зміст курсу

C# Basics

Practicing ScopesPracticing Scopes

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

cs

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

Все було зрозуміло?

Секція 6. Розділ 9
course content

Зміст курсу

C# Basics

Practicing ScopesPracticing Scopes

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

cs

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

Все було зрозуміло?

Секція 6. Розділ 9
some-alt