Programming Windows: Hello, .NET Framework and Windows Forms (Premium)

While most of Microsoft’s public .NET pronouncements involved web services, .NET also brought a major upgrade to Windows app development: the .NET Framework and its Windows Forms class libraries and Visual Studio.NET integration. Here, we’ll examine some of those advances.

As you may recall, the Windows API (Win32) was a flat, unorganized collection of many thousands of confusing C-based functions. But the .NET Framework was---and still is---an object-oriented and organized hierarchical class library consisting of logical containers called namespaces. A namespace can contain other namespaces, classes representing various objects, most of which are further sub-classed to create more specific objects, and other items. Each object provides a variety of fields, properties, and methods for developers to access.

The .NET Framework’s hierarchical nature solved many of the problems with Win32, key among them that Win32’s flat, disorganized nature meant that every function name in the Windows API had to be unique. But once you move to a hierarchical system, that limitation disappears. Indeed, you will see the same method names in various classes throughout the .NET Framework. Every interactive control, for example, has a Click() method. What makes each unique is their fully qualified name, which includes their containing namespaces and classes.

The .NET Framework also solved some of the technical limitations of classic Visual Basic, which was object-based and not object-oriented. This is not a semantical distinction. In a truly object-oriented system like the .NET Framework, subclasses inherit the capabilities of the classes from which they derive, and they evolve those capabilities as needed. A low-level class like Control provides basic features, but control subclasses that derive from it---Button, TextBox, and so on---provide more specific functionality.

That’s just the beginning of the benefits of .NET, which also provides memory management, garbage collection, structured exception handling, simpler ways to access and interoperate with COM/DCOM/COM+, and other important features. But let’s stick with the .NET Framework and how it impacted Windows app development.

The topmost class in the .NET Framework is called, appropriately enough, System. Below System are various other namespaces, including Media, Security, Text, Timing, and others. System also has classes of its own, including the Console class that is used to create console (command line) applications. Console, in turn, has events, properties, and methods. We use Console methods like Write() and WriteLine() to write text to the console window, and methods like Read(), ReadKey(), and ReadLine() to read input from the user.

Looked at another way, the console’s Write() method has a fully qualified name of System.Console.Write(). But in C#, we use the using keyword to import a namespace like System into a code project so that we don’t need to be so verbose.

A ...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC