Vertika Chauhan
Drawback of using static member globally inside the class in c#

Only one copy of static member is created regardless of how many instance of class is created . This will work fine if your application is single user but for multiple user if uses same class then this static member will create problem as it will not reset the value for different user session and will assign the value which is used by previous session user .So while having multiple session in your application use static keyword wisely

By Vertika Chauhan in .NET on May 21 2020
  • Pranam Bhat
    May, 2021 27

    Static class does not allow user to create instances of the class as well as it restrict the user to inherit any data members/functions to derived class. So, imagine a situation where we dont want a user to create instance of class or dont want user to inherit it to child class.Use a static class to contain methods that are not associated with a particular object. For example, it is a common requirement to create a set of methods that do not act on instance data and are not associated to a specific object in your code. You could use a static class to hold those methods.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS