- Static is keyword. You can declare variable, method and class to be static, when you declare variable to be static then it is shares among all the object of this class as show in example.
- When you declare any variable or method to be static then you have no need to create class of this you can access directly by its name like "ClassName.VariableName"
- When you declare any class to be static then this class only contains static member and static methods.
- When you declare static method then it only use static variable (member) of this class.
Example:
namespace CA_Static
{
class student
{
// define static variable that is shared
private static int member=0;
public void increment()
{
member++;
}
public static int getmember()
{
return member;
}
}
class Program
{
static void Main(string[] args)
{
student objstd = new student();
objstd.increment();
student objstd1 = new student();
objstd1.increment();
student objstd2 = new student();
objstd2.increment();
Console.WriteLine(student.getmember());
}
}
}
Output:
3
- how to crack IDM
- How to change name of start button in xp
- how to connect to facebook without Internet connec...
- How to customize send to menu.
- How to hide folder without any software.
--
/\/ir@\/ <(.'.)>
0 comments:
Post a Comment
Thanks for comment