Last post Jan 19, 2013 10:52 AM by pro.shailendra
Jan 19, 2013 12:40 AM|gurunguns|LINK
I am going to make manager for my controllers. But stuck with architectural appoach.
what is difference between Static method & Static class with static method?
which one to be used?
Jan 19, 2013 10:32 AM|Real4ever|LINK
It depends on your needs, kindly provide some details about your logic so we can find the most efficient way.
very detailed description with example could be found here http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx
Jan 19, 2013 10:44 AM|ramramesh|LINK
Jan 19, 2013 10:52 AM|pro.shailendra|LINK
The main features of a static class are:
They only contain static members.
They cannot be instantiated.
They are sealed.
They cannot contain Instance Constructors
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. Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state.
A non-static class can contain static methods, fields, properties, or events. The static member is callable on a class even when no instance of the class has been created.
The static member is always accessed by the class name, not the instance name. Only one copy of a static member exists, regardless of how many instances of the class are created.
Static methods and properties cannot access non-static fields and events in their containing type, and they cannot access an instance variable of any object unless it is explicitly passed in a method parameter.
Two common uses of static fields are to keep a count of the number of objects that have been instantiated, or to store a value that must be shared among all instances. Static methods can be overloaded but not overridden, because they belong to the class,
and not to any instance of the class. Although a field cannot be declared as static const, a const field is essentially static in its behavior. It belongs to the type, not to instances of the type.