Readonly Keyword in C#

Sourav.Kayal
Posted by Sourav.Kayal under C# category on | Points: 40 | Views : 751
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data;
using System.Xml;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Threading;
namespace BlogProject
{
class StaticTest
{
public static readonly Int32 Value = 100;
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(StaticTest.Value);
//It is not allowed to set data in read only variable
StaticTest.Value = 200; //It is Wrong
Console.ReadLine();
}
}
}

Comments or Responses

Login to post response