Rikam Palkar
Define static in c#?
By Rikam Palkar in C# on May 19 2020
  • Shivangi Rajde
    Jul, 2020 14

    Static a modifier used in C#. It can be used for variable, methods, classes, constructor etc. Creating static classes means that the class can only contain static properties such as static variables and static methods. We cannot create instances of static classes, it simply means that it doesn’t matter how many objects of the static class are created only one copy of the static memeber will exist.

    • 2
  • Ashish Gangwar
    Jul, 2022 20

    Static is a modifier. Static can be method, variable, constructor and class.

    • Static variables can be initialized only once during lifecycle of class.
    • If we declare a method using the static modifier then it is called a static method. We can directly consume the static members within a non-static method without any restriction.
    • If we create the constructor explicitly by the static modifier, then we call it a static constructor. Static constructor is the fast block of code that gets executed under a class.
    • Class which is created by using the static modifier is called a static class. A static class can contain only static members. It is not possible to create an instance of a static class.

    • 1
  • Sonil  Kumar
    Jul, 2021 27

    Static is shared. Because you cannot have instance contructor inside static class, you can not make object of it. Static class is used with class name and having single memory allocation for all its members. Be careful while using static variable (fields) as they can will be shared accross thread, you might get unpected values if one thread update that. So use it for shared purpose only.

    • 0
  • Rikam Palkar
    May, 2020 19

    ''

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS