BasicKnowledgeCSharp/LessonsAndTasks/Lesson 37 - Область видимости, контекст переменной, конфликт областей/Program.cs

38 lines
784 B
C#
Raw Normal View History

2025-05-12 02:48:54 +03:00
/*
* Author: Nikolay Dvurechensky
* Site: https://www.dvurechensky.pro/
* Gmail: dvurechenskysoft@gmail.com
* Last Updated: 12 мая 2025 02:47:11
* Version: 1.0.3
*/
using System;
2024-10-05 09:59:53 +03:00
/*
* Область видимости, или контекст переменной
* Конфликты областей видимости
*/
class Program
{
static int a = 3;
static int aa = 3;
static void Foo()
{
int b = 0;
int aa = 2;
Console.WriteLine(aa);
}
static void Main()
{
for (int i = 0; i < 2; i++)
{
++i;
}
Foo();
a++; // Область видимости и конктекст переменной - это одно и то же
Console.ReadKey();
}
}