using System;
namespace accessspecifier
{
class constant
{
public const int i = 44;
public static int a = 22;
public const string str = "anurag";
int n = 34;
public static void Main(string[] args)
{
Console.WriteLine("i={0}", i);//44
Console.WriteLine("i={0}", constant.i);//44
a = a + 1;
Console.WriteLine("a={0}", a);//this will work and the
output will be 23; as a is static;
//i =
34;//Error 1 The left-hand side of an assignment must be a variable, property
or indexer//you cannot change the constant value....
//n = n
+ 1;//wrong first you will not get the n when you press n as above its not
static
//Console.WriteLine(n);
Console.ReadLine();
}
}
}
No comments:
Post a Comment