---
title: "What is the difference between constants and read-only variables that are used in programs?"  
description: "What is the difference between constants and read-only variables that are used in programs?"  
author: "Sumit Kesarwani"  
published: 2014-09-02  
updated: 2020-09-15  
canonical: https://www.mindstick.com/interview/2109/what-is-the-difference-between-constants-and-read-only-variables-that-are-used-in-programs  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# What is the difference between constants and read-only variables that are used in programs?

Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are

Constants:

Constants are dealt with at compile-time.

Constants supports value-type variables.

Constants should be used when it is very unlikely that the value will ever change.

Read-only:

Read-only variables are evaluated at runtime.

Read-only variables can hold reference type variables.

Read-only variables should be used when run-time calculation is required.

## Answers

### Answer by Sumit Kesarwani

Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are

Constants:

Constants are dealt with at compile-time.

Constants supports value-type variables.

Constants should be used when it is very unlikely that the value will ever change.

Read-only:

Read-only variables are evaluated at runtime.

Read-only variables can hold reference type variables.

Read-only variables should be used when run-time calculation is required.


---

Original Source: https://www.mindstick.com/interview/2109/what-is-the-difference-between-constants-and-read-only-variables-that-are-used-in-programs

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
