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.

  • Output

    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#.

    One thought on “C# Static method and variables”

    1. Hello Sir Thanx for You this is Osm Website for beginner of Opps Concept thanku Again sir
      Hello sir i am .net developer give you some ideas? How do I apply the concept of Oops to my Real Project, like a scoop like interface abstraction redesign please help

    Leave a Reply

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