Ujjval Shukla
Why we use static class?
By Ujjval Shukla in C# on Jan 29 2016
  • Ammar Shaukat
    Jul, 2017 18

    Static classes are used in such cases where we need some utility functions and Properties. Utility functions are those functions which are very common in some software and everyone in that particular software is making use of those functions. so it does not make sense every time to create an object for such a class which is being used time to time by many programmers. You can take example of Built in Console Class of C# .

    • 10
  • Pankaj  Kumar Choudhary
    Feb, 2016 9

    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 A static class can make your implementation simpler ,safe and faster because you do not have to create an object in order to invoke its methods.

    • 8
  • Mohammed Deeb Hammoudeh
    Dec, 2016 15

    to access a particular class from anywhere inside the solution and no need to create object to access it just use it directly.

    • 6
  • kiran kumar
    Oct, 2016 7

    If you don't want to create an instance of the class and If you want to access the class members from any where in the application with out creating object of it then we use static classes.

    • 5
  • Anil Kumar Murmu
    Feb, 2016 2

    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 don't want user to inherit it to child class. one should go with Static class.

    • 3
  • Naveen Bisht
    Jun, 2016 22

    if we don't need instance, and also if we do not want to inheritance.

    • 2
  • Rajneesh Dixit
    Mar, 2020 12

    Static Classes are used in such cases where we need some utility functions and properties. Utility functions are those functions which are very common in some software and everyone in that particular software is making use of those functions. so it does not make sense every time to create an object for such a class which is being used time to time by many programmers.

    • 1
  • Sanjoy Pal
    Apr, 2018 9

    As static class is sealed, so no class can inherit a static class as well as it does not allow user to create instance of the class.So you do not need to create instance every time when you invoke its methods , As a result performance of your program will increase.

    • 1
  • Abhishek Panigrahi
    Sep, 2017 6

    A static class does not allow us to create an instance of it using the new keyword, rather it can only contain static member and that static member is executed only once by creating a static constructor, resulting which the performance of our program will increase rather than creating multiple instances of that class.Also when we are declaring a class as static then we cannot have constructor overloading too...Hope my answer resolve your problem.

    • 1
  • Vineet Kumar
    Jan, 2017 13

    In order to provide common utilities which include functions and fields/properties.

    • 1
  • Mohammed Deeb Hammoudeh
    Dec, 2016 15

    to access a particular class from anywhere inside the solution and no need to create object to access it just use it directly.

    • 1
  • G Krishna  Rao
    May, 2019 9

    Static Class do not required the object of a class to initialization of execution. Without creating object also the members are accessible.Safer and Faster

    • 0
  • John Mondragon
    Mar, 2019 12

    A static class is pure evil, creates tightly coupled code, AVOID them at all cost, unless you are an evil developer who wants to make the world a worse place.https://codeburst.io/static-classes-are-evil-or-make-your-dependencies-explicit-af3e73bd29ddhttps://blogs.msdn.microsoft.com/nickmalik/2005/09/06/are-helper-classes-evil/

    • 0
  • Bharathi Raja
    Jan, 2018 20

    Making a class static just prevents people from trying to make an instance of it. If all your class has are static members it is a good practice to make the class itself static.

    • 0
  • Ammar Shaukat
    Jul, 2017 18

    Static classes are used in such cases where we need some utility functions and Properties. Utility functions are those functions which are very common in some software and everyone in that particular software is making use of those functions. so it does not make sense every time to create an object for such a class which is being used time to time by many programmers. You can take example of Built in Console Class of C# .

    • 0
  • Khaleek Ahmad
    Feb, 2017 3

    1. Static class is faster 2. Only single object grantee class which will be created by compiler.Please visit for detail. https://interview-preparation-for-you.blogspot.in/2011/09/static-class.html

    • 0
  • Kshamesh Atnoorkar
    Jan, 2017 5

    Static Class vs Instance Class. They are two different things that their members can be accessed with or without an instance of a class. If I need to know the possible ways from one source to another destination then there are multiple possibilities then it makes sense to have Instance Class to store all the routes. And if I am just returning the addition of two numbers then I don't need an instance to store a result. e.g Math class in. NET Framework.

    • 0
  • Manoj Kumar Duraisamy
    Dec, 2016 30

    we can access the object of the classes without creating instance, directly call the methods using class name. Note : If we want to declare a method as a web Method we must declare it as a static method.

    • 0
  • Subhashkumar Yadav
    Dec, 2016 19

    It makes it obvious to users how the class is used. For instance, it would be complete nonsense to write the following code:Math m = new Math(); C# doesn’t have to forbid this but since it serves no purpose, might as well tell the user that. Certain people (including me) adhere to the philosophy that programming languages (and APIs …) should be as restrictive as possible to make them hard to use wrong: the only allowed operations are then those that are meaningful and (hopefully) correct.

    • 0
  • Sailaja Tummuru
    Dec, 2016 12

    Can I have one real time senario?

    • 0
  • Khaja Moizuddin
    Dec, 2016 2

    if we dont want to access the members from other class (non static) class then we go for static if we dont want to inherit too

    • 0
  • Ananth G
    Oct, 2016 21

    if we make a class as static we don't create instance.static class have static member variable and methods only.

    • 0
  • Srinivasan Anbarasan
    Jul, 2016 16

    we can't inherit static class & static method cannot be overridden.

    • 0
  • Hari Shanker
    Jul, 2016 11

    1.If we specify static keyword for the classes it will not allow us to create an instance of a class 2.static class and static methods will allow only only static fields and static functions ,non static are not applicable 3.all the static members will get be allocated memory as soon the class loads for the first time (Run time)

    • 0
  • Deeksha Pandit
    Jul, 2016 4

    1) Static class are being used when you want to make some util methods like you want to pass some data to a method and want some processing over it and get result from there. 2) You do not need to make object for accessing its properties and methods. You use class name and dot operator and properties /Methods.

    • 0
  • Naveen Bisht
    Jun, 2016 22

    if we don't need instance, and also if we do not want to inheritance.

    • 0
  • Vasanth Natarajan
    Jun, 2016 10

    They're very easy to use, no instantiation, no disposal, just fire'n'forget. I guess this was my first unwitting attempt at creating a service oriented architecture - lots of stateless services that just did their job and nothing else.

    • 0
  • Keerthi Venkatesan
    Jun, 2016 8

    The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created. Static classes are sealed and therefore cannot be inherited. They cannot inherit from any class except Object.

    • 0
  • Avikshith Aradhya
    Jun, 2016 6

    when we do not need to create an instance of the class then we will use static class.

    • 0
  • Avikshith Aradhya
    May, 2016 30

    Static class is used when we don't want to create instance of the class. Static classes are sealed and therefore cannot be inherited. They cannot inherit from any class except Object.

    • 0
  • Thiruppathi R
    May, 2016 25

    http://www.codeproject.com/Articles/15269/Static-Keyword-Demystified Refer this easy to understand

    • 0
  • Rubiya Rajamanickam
    Apr, 2016 29

    a static class cannot be instantiated. In other words, you cannot use the new keyword to create a variable of the class type. Because there is no instance variable, you access the members of a static class by using the class name itself

    • 0
  • Barkha Gupta
    Apr, 2016 12

    A static class can be used as a convenient container for sets of methods that just operate on input parameters and do not have to get or set any internal instance fields

    • 0
  • Vincent Maverick Durano
    Apr, 2016 12

    I normally use static class when defining extension, helper or utility methods.

    • 0
  • Keerthi Venkatesan
    Apr, 2016 11

    Making a class static just make us from trying to make an instance of it. If all your class has are static members it is to make the class itself static.

    • 0
  • Sreekanth Reddy
    Mar, 2016 15

    creation of instance can be restricted with static classes.

    • 0
  • Surya Pratap Singh
    Mar, 2016 6

    Use a static class as a unit of organization for methods not associated with particular objects. Also, a static class can make your implementation simpler and faster because you do not have to create an object in order to call its methods. It is useful to organize the methods inside the class in a meaningful way, such as the methods of the Math class in the System namespace.

    • 0
  • Munesh Sharma
    Feb, 2016 9

    A static class can make your implementation simpler and faster because you do not have to create an object in order to invoke its methods. It is useful to organize the methods inside the class in a meaningful way, such as the methods of the Math class in the System namespace.

    • 0
  • Vivek Kumar
    Feb, 2016 7

    We create static class, because we call it's method directly without create it's object.Check the following reference for more details about static class and static keyword http://www.dotnetperls.com/static:

    • 0
  • Nishant Mittal
    Feb, 2016 1

    Without creation of object you can call the method of the class in case class in static , isn'nt its great

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS