When your day work involves programming in Delphi and you have programmed in a language such as C++ or C# which allow static class you sometimes miss them as they are an useful resource.
What's a static class
A static class is, simply put, a class that provides some methods, properties and even fields but which doesn't need an instance to be used, that is, you don't need to create an instance of the class in order to call its methods or access its properties.
Actually, in C# for example, this separation reach the method, field and property level, that is, it is possible to define some methods to be static while other ones are not, and so such methods may be called without having to instantiate the class. In C# that looks more or less like this:
public class MyStaticClass
{
private int m_value;
public MyStaticClass()
{
m_value = 0;
}
public int Value(){ return m_value; }
public static int ModDivision(int numerator, int denominator)
{
int result = numerator;
while (result < denominator)
{
result = result - denominator;
}
return result;
}
}
Enviado por Cracky el Mar, 2005-12-27 15:34.