Const vs Readonly vs Init in C# - Complete Guide

Const vs Readonly vs Init in C# - Complete Guide

Understanding the difference between const, readonly, and init is extremely important for mastering C# fundamentals and clearing .NET interviews.

🎥 Watch the full explanation video here: Const vs Readonly vs Init in C#


1️⃣ What is const in C#?

A const field is a compile-time constant. Its value must be known at compile time and must be assigned at declaration.

public const double PI = 3.14159;
  • Implicitly static
  • Must be assigned at declaration
  • Cannot be changed
  • Value is embedded at compile time

⚠ Important Interview Point

If you change a const value in a library, all referencing assemblies must be recompiled.


2️⃣ What is readonly in C#?

A readonly field is a runtime constant. It can be assigned either at declaration or inside the constructor.

public class Student
{
    public readonly DateTime AdmissionDate;

    public Student()
    {
        AdmissionDate = DateTime.Now;
    }
}
  • Evaluated at runtime
  • Can use runtime values
  • Can only be assigned in constructor or declaration

3️⃣ What is init in C#?

The init keyword (introduced in C# 9) allows properties to be set only during object initialization.

public class Employee
{
    public string Name { get; init; }
}

var emp = new Employee { Name = "Sudipto" };
  • Works with properties
  • Allows object initializer syntax
  • Becomes immutable after initialization

🔎 Constructor Behavior

When using object initializer syntax:

var emp = new Employee { Name = "Sudipto" };

The constructor runs first, and then the property is assigned.


🧠 Key Differences Summary

Feature const readonly init
Evaluated At Compile Time Runtime Runtime
Works On Fields Fields Properties
Assigned in Constructor No Yes No
Immutable After Creation Yes Yes Yes

🎯 Final Thoughts

If you want strong fundamentals in C#, you must clearly understand when values are determined — compile time vs runtime — and how immutability works in .NET.

For deep .NET learning and 1-to-1 training, feel free to explore more resources.


🚀 Keep Learning. Stay Fundamental.

Class Guidelines for Effective 1-on-1 Learning

To keep every session productive and distraction-free, please follow these simple guidelines:

  • Quiet Environment: Join from a calm, private room with minimal background noise. Avoid public or noisy places.
  • No Interruptions: Inform family/roommates in advance. Keep doors closed during class.
  • Mobile on Silent / DND: Set your phone to Silent or Do Not Disturb to prevent calls and notifications.
  • Be Fully Present: Do not multitask. Avoid attending to other calls, visitors, or errands during the session.
  • Stable Setup: Use a laptop/desktop with a stable internet connection and required software installed (Visual Studio/.NET, SQL Server, etc.).
  • Punctuality: Join on time so we can utilize the full session effectively.
  • Prepared Materials (If any): Keep project files, notes, and questions ready for quicker progress.

Following these guidelines helps you focus better and ensures I can deliver the best learning experience in every class.

Schedule a Quick 10-Minute Call

I prefer to start with a short 10-minute free call so I can understand:

  • Your learning objectives and career goals
  • Your current skill level
  • The exact topics you want to learn

Why? Because course content, teaching pace, and fees all depend on your needs — there’s no “one-size-fits-all” pricing. Please leave your details below, and I’ll get back to you to arrange a convenient time for the call.




Note: Payment is made only after your first class, once you’re completely satisfied. However, fees paid after the first class are non-refundable. This helps maintain scheduling commitments and allows me to reserve your preferred time slot with full attention.

Google Review Testimonials

.NET Online Training
Average Rating: 4.9
Votes: 50
Reviews: 50