What is static keyword in c#?

Asked 5 years ago
Updated 5 years ago
Viewed 587 times

0

What is static keyword in c#?


1 Answer


0

The static keyword in c # is used to declare static class or static data members or static property. A static class can only contain static data members, static methods and static constructor. We can access those static data members directly with a class name instead of creating on object of a class to access those properties.
Following is the example of defining a class with static properties and those can be access directly with a type instead of specific object name.
class User

{
public static string name, location;
public static int age;
}

answered 5 years ago by Pradeep kumar Patel

Your Answer