Interviews - C# Corner

Ujjval Shukla
What is the advantage of static class over class ?
By Ujjval Shukla in C# onJan 29 2016
  • Vinay Singh
    Jun, 2016 8

    In simple way we van say for accessing static class don't need to create instance and for normal class need to create instance

    • 3
  • Vinay Singh
    Jun, 2016 8

    In simple way we van say for accessing static class don't need to create instance and for normal class need to create instance

    • 2
  • nitin  patil
    Mar, 2016 30

    http://www.codeproject.com/Articles/891433/Must-Remember-Key-Concepts-to-Keyword-StaticAbove URL solves almost all queries related to static.

    • 2
  • Jayesh Vaghasiya
    Mar, 2016 5

    Static class members not a change values in using child class method and fiction. 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.and this class data not use child class inherit but data members/functions in child class and not a changes of a data in using child class

    • 2
  • 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 dont want user to inherit it to child class. one should go with Static class.

    • 2
  • Bhavani Sharma
    Apr, 2018 17

    1. fast as compared to normal class.2. Provide extension methods.3. globally available for all users.4. no need to instantiate.5. easy approch for singleton .

    • 1
  • Avinash Avate
    Dec, 2016 28

    by using static class we dont need to create object of that class. we can easily access method of that class. genrally we used static class to write helper methods

    • 1
  • Ravi Chandra Yadav
    Nov, 2016 18

    The following list provides the main features of a static class:Contains only static members.Cannot be instantiated.Is sealed.Cannot contain Instance Constructors.

    • 1
  • Rajendra Mote
    Aug, 2016 26

    No need to create object to access meber of static class.

    • 1
  • Vinay Singh
    Jun, 2016 8

    In simple way we van say for accessing static class don't need to create instance and for normal class need to create instance

    • 1
  • kapil kumar
    Jun, 2016 7

    static class does not require any object to call any function or attribute

    • 1
  • Vivek Kumar
    Feb, 2016 7

    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.

    • 1
  • Deependra Kushwah
    Feb, 2018 22

    When the state of the object is not going to change then you can use a static class. A common example is your configuration data which will be common for the entire application.

    • 0
  • Ayappan Alagesan
    Feb, 2017 12

    No need of creating instance for static class is the major advantage.

    • 0
  • Khaleek Ahmad
    Feb, 2017 3

    Compiler ensure that no one can create object of static class. Static class are fast in comparison of simple class because no object needed. Static class behave like sealed classes no one can inherit the.Fore more properties you can visthttps://interview-preparation-for-you.blogspot.in/2011/09/static-class.html

    • 0
  • Vineet Kumar
    Jan, 2017 13

    static classes are meant to provide common functionalities and properties. The main advantage is that we need not to create any object in order to access these. All the members under it works like global for all the other classes.

    • 0
  • Kshamesh Atnoorkar
    Jan, 2017 5

    I don't see a reason that we should try to see advantages of Static Class over Instance Class. They are two different things that their members can be accessed with or without an instance of a class. Just because you don't need an instance, it doesn't mean it's an advantage. 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
  • Sreekanth Reddy
    Dec, 2016 7

    A static class doesn't require a instance as like normal class for accessing class members.

    • 0
  • Manav Pandya
    Nov, 2016 28

    static class runs automaticall by just accessing with class name , and normal class need to initialized by object

    • 0
  • Thennarasu N
    Oct, 2016 20

    If your class doesn't store any state, then use a Static class.If it stores state and you require a single instance, then (maybe) use a Singleton.Otherwise use a regular class

    • 0
  • Thennarasu N
    Oct, 2016 20

    If your class doesn't store any state, then use a Static class.If it stores state and you require a single instance, then (maybe) use a Singleton.Otherwise use a regular class

    • 0
  • Chirag Solanki
    Oct, 2016 5

    Static class is a pre compiled class so it can access directly without compiling run time.

    • 0
  • Dinesh Kumar
    Aug, 2016 31

    If you are using Static class then no need to Create Class instance. and one more thing Static class only take Static Method Ex- using System; public static class staticclass {public static void show(){Console.WriteLine("Hello");}static void Main(){staticclass.show();} }

    • 0
  • Dinesh Kumar
    Aug, 2016 31

    If you are using Static class then no need to Create Class instance. and one more thing Static class only take Static Method Ex- using System; public static class staticclass {public static void show(){Console.WriteLine("Hello");}static void Main(){staticclass.show();} }

    • 0
  • Sandeep Singh
    Aug, 2016 18

    In the main method we can directly access the static members because main method is also a static method where as we have to create instance to consume the member of instance class.

    • 0
  • Sandeep Singh
    Aug, 2016 14

    Static class can contain only static member in it, So there is no need to create the instance of the static class to consume the members.

    • 0
  • Soumalya Das
    Aug, 2016 7

    in case of static class you dont need to create an instance

    • 0
  • Shailendra Saxena
    Jul, 2016 25

    when we want to access members of class without creating objects, static class may be used. The advantage of static class over class is that in static class members can be directly access by classname.membername but in class we need to create instances for accessing members of class.

    • 0
  • Venkatesan Arasappan
    Jul, 2016 19

    We don't need to create Objects we can directly call static class methods you can use extension methods.We can use it if you are using the classes frequently.

    • 0
  • Jorge Anzardo
    Jul, 2016 5

    The best approach is to rephrase the question to: when to use static class or concrete class. The answer is it depends on the application. For example a hammer does not have an advantage over a screwdriver. It depends on the work.Look at the application from an OOP perspective. Look up the characteristics of classes on the Microsoft developers site. Then ask yourself how your software will represent the information. Is the information unique? What is the scope? Performance concerns? Organization of methods? Best wishes

    • 0
  • Jorge Anzardo
    Jul, 2016 5

    The best approach is to rephrase the question to: when to use static class or concrete class. The answer is it depends on the application. For example a hammer does not have an advantage over a screwdriver. It depends on the work.Look at the application from an OOP perspective. Look up the characteristics of classes on the Microsoft developers site. Then ask yourself how your software will represent the information. Is the information unique? What is the scope? Performance concerns? Organization of methods? Best wishes

    • 0
  • Deeksha Pandit
    Jul, 2016 4

    1) If you are using a static class , you do not need to create instance for accessing it's properties and methods. 2) Basically static classes are used to make Utility methods (Utils).

    • 0
  • Bineesh  Viswanath
    Jun, 2016 23

    Static members are managed by CLR

    • 0
  • Omendra  Gangwar
    Jun, 2016 15

    In the simple way can say that no need to create instance in static class and it is mandatory in class.

    • 0
  • hari ratnam
    Jun, 2016 9

    static classes can'nt be instantiated bcoz static calsses is a sealed class we can'nt create the object by using create the object only instatnce variables

    • 0
  • hari ratnam
    Jun, 2016 9

    static class can'nt be instatntiated bcoz static classes are sealed class we can'nt create the object by using create the object only instance variables

    • 0
  • Vinay Singh
    Jun, 2016 8

    In simple way we van say for accessing static class don't need to create instance and for normal class need to create instance

    • 0
  • Thiruppathi R
    May, 2016 25

    Static Class is no object of static class can be created and must contain only static members

    • 0
  • Tijo Joy
    Apr, 2016 28

    Static Classes have only one object life,Hence we cannot create multiple objects of static classes but normal classes can be instantiated for creating many objects of the same class We use Static classes in scenarios in like creating a utilities class, implementing a singleton pattern etc.

    • 0
  • Rahul Chavan
    Apr, 2016 6

    Static classes are used for 1) Data Caching: e.g- List of Country or States 2) Utility Classes: e.g.- You can create Utility classes as static as there is no need of creating object of these classes. 3) You Can Access methods / variables of Static class without creating object of the class. 4) These Classes are loaded when application is loaded in memory.

    • 0
  • Rahul Chavan
    Apr, 2016 6

    Static classes are used for 1) Data Caching: e.g- List of Country or States 2) Utility Classes: e.g.- You can create Utility classes as static as there is no need of creating object of these classes. 3) You Can Access methods / variables of Static class without creating object of the class. 4) These Classes are loaded when application is loaded in memory.

    • 0
  • satya srinivas
    Apr, 2016 5

    When all members/porperties in a class are static then use declare a class as static When you wnat to maintain the unique value for a varible for multiple threads then use Static

    • 0
  • Sunil Babu
    Apr, 2016 2

    Static class is a class with only one instance.Used for building utility codes and singleton architecture.

    • 0
  • Keerthi Venkatesan
    Mar, 2016 31

    By declaring a method using the static keyword, you can call it without first creating an object because it becomes a class method that belongs to a class rather than an object.

    • 0
  • vaibhav Hedaoo
    Mar, 2016 25

    static classes are used when a class provides functionality which is not specific to any instance. If you want an object to be shared between multiple instances you will use a static class. they can not be instantiated , it can not be inherited, it can have only static members it can have only static constructor.

    • 0
  • Sreekanth Reddy
    Mar, 2016 8

    Class : To access any members of the class we need to take the help of the instance. Static Class : No need to create instance. Directly with the help of class name we can access the members.

    • 0
  • 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.

    • 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
  • Ujjval Shukla
    Jan, 2016 29

    1.)When we have a normal class and its methods being used very frequently in a given app, then it would speed up things if we made this class a static class with static methods. This is because there is always a cost incurred in terms of resource usage ( CPU, memory, time) EVERY TIME a normal class is instantiated, whereas for static class its only a ONE-TIME cost when static constructor is FIRST called.2.)The main advantage of Static Classes come when there is a need to use WebMethod or a webservice, so that the application can call the static method without creating an object.http://www.geekinterview.com/question_details/89408http://www.geekinterview.com/talk/15090-why-we-create-static-class-c.html

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS