Saturday, 9 January 2016

C#.NET Const

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

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
        }
    }

}

No comments:

Post a Comment