error CS0122: 'Account.balance' is inaccessible due to its protection level means you used a member that is private to its class. A field written with no access modifier, like decimal balance;, is private. Either use a public method or property the class offers for that job, or make the member public on purpose.

The better fix is usually not to open the field: add a public method that changes it with rules (a deposit must be positive), and keep the field private.

The error

...\Program.cs(2,9): error CS0122: 'Account.balance' is inaccessible due to its protection level [...\FixLab.csproj]
...\Program.cs(7,13): warning CS0649: Field 'Account.balance' is never assigned to, and will always have its default value 0 [...\FixLab.csproj]
Build FAILED.

The folder part of the paths was shortened to ...; nothing else was changed.

Why it happens

var account = new Account();
account.balance = 500;
Console.WriteLine($"Balance: {account.Balance}");

class Account
{
    decimal balance;

    public decimal Balance => balance;
}

Class members in C# are private unless you say otherwise. balance has no modifier, so only code inside Account may touch it, and the assignment on line 2 is outside. The public Balance property only reads the value, so there is no public way to change it. The CS0649 warning in the same build is a side effect: since nothing inside the class ever assigns balance, the compiler notes it will stay 0.

Read the quoted name in the message first: it is the exact member that is hidden from the line that uses it, which tells you where to look.

The fix

var account = new Account();
account.Deposit(500);
Console.WriteLine($"Balance: {account.Balance}");

class Account
{
    decimal balance;

    public decimal Balance => balance;

    public void Deposit(decimal amount)
    {
        if (amount <= 0)
            throw new ArgumentOutOfRangeException(nameof(amount));
        balance += amount;
    }
}

The field stays private and the class decides how it may change. The project built with warnings treated as errors (the CS0649 warning was gone too, because Deposit assigns the field) and printed Balance: 500.

Writing public decimal balance; would also compile, but then any code can set any balance, including a negative one. If you only need outside code to read and set a value with no rules, use a property, public decimal Balance { get; set; }, rather than a public field.

How it was reproduced

A dotnet new console project on .NET SDK 10.0.403 (net10.0, nullable and implicit usings on, no packages) with the program above. dotnet build --no-incremental failed with CS0122 and the CS0649 warning; the fixed version passed dotnet build --no-incremental -p:TreatWarningsAsErrors=true and ran.

Frequently asked

What is the default access modifier for a field in C#?
Private. A field, method or property declared inside a class without public, internal or protected can be used only by code inside that class.
How do I fix inaccessible due to its protection level?
Use a public member the class already offers for the job, or add one, such as a method that changes the field with checks. Making the field itself public works but removes the class's control over its own data.
Should I make the field public or use a property?
Use a property, or a method when changes need rules. A public field cannot validate what is stored in it; a method such as Deposit can refuse a bad amount.

More decoded compiler errors are in the Fixes category.