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.
Interviews40 answers
Why we use static class?
40 Answers
Rajneesh DixitPosted Mar 11, 2020, 10:50 PM EDT
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
G Krishna RaoPosted May 9, 2019, 5:47 PM EDT
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-af3e73bd29dd
https://blogs.msdn.microsoft.com/nickmalik/2005/09/06/are-helper-classes-evil/
John MondragonPosted Mar 12, 2019, 2:17 PM EDT
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.
Sanjoy PalPosted Apr 9, 2018, 5:30 AM EDT
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.
Bharathi RajaPosted Jan 19, 2018, 8:55 PM EST
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.
Abhishek PanigrahiPosted Sep 6, 2017, 11:08 AM EDT
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# .
Ammar ShaukatPosted Jul 18, 2017, 12:42 AM EDT
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# .
Ammar ShaukatPosted Jul 18, 2017, 12:42 AM EDT
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
Khaleek AhmadPosted Feb 2, 2017, 8:56 PM EST
In order to provide common utilities which include functions and fields/properties.
Vineet KumarPosted Jan 12, 2017, 8:44 PM EST
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.
Kshamesh AtnoorkarPosted Jan 5, 2017, 11:52 AM EST
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.
Manoj Kumar DuraisamyPosted Dec 30, 2016, 1:57 AM EST
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.
Subhashkumar YadavPosted Dec 18, 2016, 11:25 PM EST
to access a particular class from anywhere inside the solution and no need to create object to access it just use it directly.
Mohammed Deeb HammoudehPosted Dec 14, 2016, 11:30 PM EST
to access a particular class from anywhere inside the solution and no need to create object to access it just use it directly.
Mohammed Deeb HammoudehPosted Dec 14, 2016, 11:30 PM EST
Can I have one real time senario?
Sailaja TummuruPosted Dec 12, 2016, 4:53 PM EST
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
Khaja MoizuddinPosted Dec 2, 2016, 4:30 AM EST
if we make a class as static we don't create instance.
static class have static member variable and methods only.
Ananth GPosted Oct 21, 2016, 12:07 AM EDT
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.
kiran kumarPosted Oct 7, 2016, 6:17 AM EDT
we can't inherit static class & static method cannot be overridden.
Srinivasan AnbarasanPosted Jul 15, 2016, 8:17 PM EDT
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)
Hari ShankerPosted Jul 11, 2016, 3:16 AM EDT
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.
Deeksha PanditPosted Jul 4, 2016, 9:34 AM EDT
if we don't need instance, and also if we do not want to inheritance.
Naveen BishtPosted Jun 22, 2016, 2:43 AM EDT
if we don't need instance, and also if we do not want to inheritance.
Naveen BishtPosted Jun 22, 2016, 2:43 AM EDT
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.
Vasanth NatarajanPosted Jun 10, 2016, 5:44 AM EDT
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.
Keerthi VenkatesanPosted Jun 7, 2016, 9:49 PM EDT
when we do not need to create an instance of the class then we will use static class.
Avikshith AradhyaPosted Jun 6, 2016, 1:57 AM EDT
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.
Avikshith AradhyaPosted May 30, 2016, 6:23 AM EDT
http://www.codeproject.com/Articles/15269/Static-Keyword-Demystified
Refer this easy to understand
Thiruppathi RPosted May 25, 2016, 7:16 PM EDT
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
Rubiya RajamanickamPosted Apr 29, 2016, 4:47 AM EDT
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
Barkha GuptaPosted Apr 12, 2016, 9:10 AM EDT
I normally use static class when defining extension, helper or utility methods.
Vincent Maverick DuranoPosted Apr 12, 2016, 9:04 AM EDT
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.
Keerthi VenkatesanPosted Apr 11, 2016, 5:34 AM EDT
creation of instance can be restricted with static classes.
Sreekanth ReddyPosted Mar 15, 2016, 1:22 AM EDT
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.
Surya Pratap SinghPosted Mar 6, 2016, 5:38 PM EST
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.
Pankaj Kumar ChoudharyPosted Feb 9, 2016, 4:20 PM EST
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.
Munesh SharmaPosted Feb 8, 2016, 7:53 PM EST
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:
Vivek KumarPosted Feb 6, 2016, 10:04 PM EST
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.
Anil Kumar MurmuPosted Feb 1, 2016, 8:24 PM EST
Without creation of object you can call the method of the class in case class in static , isn'nt its great
Nishant MittalPosted Feb 1, 2016, 1:52 AM EST




























