- using System;
- namespace BagarRajuClassConsoleProj.ModuleClasses
- {
- public class Greeks
- {
- private Greeks() //private constructor
- { }
- public static int count = 20;
- }
- public class TestGreek
- {
- Greeks.count = 10; //gives error
- }
- }
Why is static field inaccessible in another class?
In the above code, the "count" field is inaccessible in TestGreek class.
It arises following an error message.
The name 'count' does not exist in the current context.
But as per my knowledge, the static fields can accessible in another class.

Sachin SinghPosted Feb 18, 2021, 10:50 AM