How to assign values to variables in C#?

CsharpProgrammingServer Side Programming

A variable is a name given to a storage area that our programs can manipulate. Each variable in C# has a specific type, which determines the size and layout of the variable's memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.

To assign values to a variable, add the value after the equal operator −

int a = 10;

Let us see how to assign values to a variable and print it


 Live Demo

using System;

namespace Demo {

   class Program {

      static void Main(string[] args) {

         int a;

         a = 100;

         Console.WriteLine("a = {0}", a);


a = 100
Updated on 20-Jun-2020 11:31:36