- Back to Home »
- C#.NET »
- C#.NET Const
Posted by :
Sudhir Chekuri
Saturday, 9 January 2016
C#.NET const keyword is used to create a variable which can be initialized with a value but cannot be assigned any value after creating it.
C#.NET program with const keyword
Program
C#.NET program with const keyword
Program
using System;
namespace ConstKeyword
{
class Program
{
static void Main(string[] args)
{
//you can intialize
const int i = 1;
//you cannot assign value
//i = 12; //error in this line
}
}
}