Static in C# 1.1
-
Dear all, I have a interview question here-- Q ) We do not have static concept in dot net 1.1,so to achieve static in 1.1 , what was the solution? Thanks in advance, Srinivas Mateti
-
Thanks..a class with private constructor and one of parameter will creates the object of that class which is read only right..... So..is the question is rigt..."Dot net 1.1 does nt have static concept?
It allows static instances, but not static classes. This basically means that the static keyword wasn't applied to classes until .NET 2; it was available as a method modifier in .NET 1/1.1 which is how the static effect was achieved.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Thanks..a class with private constructor and one of parameter will creates the object of that class which is read only right..... So..is the question is rigt..."Dot net 1.1 does nt have static concept?
Initial version of C# (.NET 1.1) did not support the concept of static classes though you could have static members in a class. C# 2.0 (.NET 2.0) introduced the concept of static classes. It is not a feature of the framework, it's just a syntactic sugar in the language which ensures that a class contains only static members, if that is what it is supposed to contain. Static classes cannot have non-static members (they can have const's), they cannot inherit from another class (implicitly inherits from System.Object) and they themselves cannot be inherited.
-
Thanks..a class with private constructor and one of parameter will creates the object of that class which is read only right..... So..is the question is rigt..."Dot net 1.1 does nt have static concept?
Static does not mean "read only". You can get a more comprehensive explanation from here[^].
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
Dear all, I have a interview question here-- Q ) We do not have static concept in dot net 1.1,so to achieve static in 1.1 , what was the solution? Thanks in advance, Srinivas Mateti
The question is wrong, as static is a modifier available in .Net since it's first version. Look at the Main method: static void Main(string[] args) { } It's static. But, as the others pointed, the keyword couldn't be used in the class declaration.
-
Dear all, I have a interview question here-- Q ) We do not have static concept in dot net 1.1,so to achieve static in 1.1 , what was the solution? Thanks in advance, Srinivas Mateti
Write a sealed class with a private constructor and only static members.
-
Dear all, I have a interview question here-- Q ) We do not have static concept in dot net 1.1,so to achieve static in 1.1 , what was the solution? Thanks in advance, Srinivas Mateti
There are static element in .NET 1.1 but no static classes. I used to use abstract classes instead of static classes. Some people might say its not clean yet it did the job.