C# Static method and variables

In this chapter you will learn:

  • What is static keyword in C# programming?
  • How to use it with functions and variables?
  • How to use static method or variable in C sharp programming?

Whenever you write a function or declare a variable, it doesn’t create instance in a memory until you create object of class. But if you declare any function or variable with static modifier, it directly create instance in a memory and acts globally. The static modifier doesn’t reference with any object.

How to: It is very easy to create static modifier with variables, functions and classes. Just put static keyword before the return data type of method.


Enter a number  7
Power of 7 = 49 __


In this chapter you learned in details about static method and variables. You also learned how to use it in program. In next chapter you will learn about Main method in C#.

Leave a Reply

Your email address will not be published. Required fields are marked *