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

Example

 Live Demo

using System;

namespace Demo {

   class Program {

      static void Main(string[] args) {

         int a;

         a = 100;

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

Output

a = 100
raja
Published on 07-Aug-2018 12:37:57
Advertisements