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

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

}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -