TGViewer
C# 1001 notes C# 1001 notes @csharp_1001_notes · 6.66K subscribers
Post #301 1.46K
​​In C#, the Scope of the variable determines the accessibility of the variable to a particular part of the application. Variables can be declared within the class, method, and code block of a loop, condition, etc.

There are three types of scopes in C#.

- Class Level Scope
- Method Level Scope
- Code-Block Level Scope

Class Level Scope

A variable declared within a class is known as a field. It has a class-level scope that can be accessed anywhere in the class, such as class methods, properties, etc.

In the above example, the Student class contains two class variables (a.k.a. fields) _firstName and _lastName. These fields can be accessed anywhere within the class, i.e., within any non-static methods and properties.

The class level variables can also be accessed out of class using class objects depending on the access modifiers. The static variables of the class can only be accessed from the static methods or properties.
More from @csharp_1001_notes
  1. Sep 28, 2026«Ядро Windows NT во многом превосходит Linux», считает исследовательница Google и бывший р…
  2. Sep 24, 2026Ваш .NET API работает локально. Готов ли он к продакшену? Чек-лист из 8 проверок перед рел…
  3. Sep 20, 2026🧩 C# Channels: сообщение попало в очередь. Почему обработчик его не получил? Два воркера…
  4. Sep 16, 2026Эта задача проверяет понимание Memory<T>, pooling, ownership, IAsyncEnumerable, cancellati…
  5. Sep 16, 2026# C# 14: хитрая задача на ArrayPool, IAsyncEnumerable и время жизни памяти Есть поток данн…
  6. Sep 14, 2026# C# 14: конкурентный кеш без race condition Реализуйте потокобезопасный кеш: public seale…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →