What do you mean by static property? Give an example?

 Posted by Tripati_tutu on 11/15/2010 | Category: C# Interview questions | Views: 3210 | Points: 40
Answer:

A property with a static keyword is considered as static property. This makes the property available to access at any time, even if no instance of the class exists. Below is the example for a static property.

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;

class Value
{
private static int i = 3;
public static int i
{
et
{
return i;
}
}
}

class Main
{
public static void Main()
{
Console.WriteLine(Value.i);
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response