Static Classes and Static Class Members
In this link Microsoft says,
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.
I learned static class the same as stated above. But for the static class Tuple introduced in .NET Framework 4 can have new keyword to create a Tuple.
var population = new Tuple(
“New York”, 7891957, 7781984,
7894862, 7071639, 7322564, 8008278);
Can anyone explain how is that possible?
The static
Tupleclass is a factory class: it’s job is just to provide an easy to way to construct tuples.In reality, there are 8 tuple classes in .NET 4:
Tuple<T1, T2>,Tuple<T1, T2, T3>and so on.Tuplefactory class which centralizes construction of the above.So, you can’t create an instance of a static class, but you can have several classes with the same name, if they have different generic arguments.