Jeetendra Gund
What is static class?
By Jeetendra Gund in C# on Mar 27 2014
  • Manju lata Yadav
    Jun, 2014 30

    A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. You access the members of a static class by using the class name itself. For example, if you have a static class that is named UtilityClass that has a public method named MethodA,: UtilityClass.MethodA();Use of static class: 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. For example, the static System.Math class contains methods that perform mathematical operations, without any requirement to store or retrieve data that is unique to a particular instance of the Math class. double dub = -3.14; Console.WriteLine(Math.Abs(dub)); Console.WriteLine(Math.Floor(dub)); Console.WriteLine(Math.Round(Math.Abs(dub)));// Output: // 3.14 // -4 // 3 A static constructor is only called one time, and a static class remains in memory for the lifetime of the application domain in which your program resides. Main features of a static class: • Contains only static members. • Cannot be instantiated. • Is sealed. • Cannot contain Instance Constructors.

    • 1
  • Mageshwaran R
    Nov, 2018 29

    Static Class you have only static members.You cannot have instance members(method,properties).

    • 0
  • Mukesh Kumar
    Sep, 2017 5

    Static can execute without main

    • 0
  • Anil Jha
    Mar, 2016 2

    1. A static class is a class which cannot be instantiated. 2. A static class can have only static members. 3. Static members of a class can by accessed by dot(.) operator. for example Employee.GetEmployee() 4. Static class is implicitly sealed. Therefore a class cannot inherit a static class.

    • 0
  • satish kumar
    May, 2015 23

    Static class is a class which cannot be instantiated.The common properties can be declared in Static class.Ex : In a school, 10 students have the same common features.So we can keep the common properties in the Static class.

    • 0
  • Kml Surani
    Apr, 2015 15

    A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. In other words, you cannot use the new keyword to create a variable of the class type

    • 0
  • Pankaj  Kumar Choudhary
    Apr, 2015 2

    Static class it a type of class whose instance can not be created. we can declare static member function , field in static class we can not create non static member function and field in a static class

    • 0
  • Sunil Gaded
    Aug, 2014 28

    1.all the members of the class are static. 2.not possible to crate the object of the static class. 3.methods r call by name of class.method name. 4.this is a sealed one

    • 0
  • Ashish
    Apr, 2014 24

    the class which doesn't need any instantiation to access its data members and methods. They can called directly by the class name.

    • 0
  • Munesh Sharma
    Apr, 2014 12

    http://www.dotnetperls.com/static-class

    • 0
  • Dileep Kumar Patel
    Apr, 2014 2

    Static class is a class which is call without any instance of objects.

    • 0
  • Palle Technologies
    Apr, 2014 2

    Static class is a class which is faster than instance class . Since Static class doesn't require object creation hence it is faster compared to instance class . Inheritance is not allowed on the static classes hence a static class can't act as a base class as well as derived class . regards Lok http://skillgun.com/csharp/interview-questions-and-answers

    • 0
  • shimab alam
    Apr, 2014 1

    Features of Static class 1. Inheritance not allow. 2. Creating instance not allow. 3. Must contain only static properties , fields , constructor and methods.

    • 0
  • Mukesh Kumar Tiwari
    Mar, 2014 27

    A static class is basically the same as a non-static class, but there is one difference: 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.. for example visit this link.. http://www.c-sharpcorner.com/uploadfile/hirendra_singh/static-classes-in-C-Sharp/

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS