Posts Tagged ‘ Classes ’

Working with Classes

… in the .NET Framework Library

I just took a closer look at classes in the .NET Framework Class Library.

The .NET Framework class library is divided into two parts: the Base Class Library and the Framework Class Library.

The Base Class Library (BCL), is a library of functionality available to all languages using the .NET Framework. The BCL provides classes which encapsulate a number of common functions, including file reading and writing, graphic rendering, database interaction, XML document manipulation etc. The BCL classes are available in both .NET Framework as well as its alternative implementations including .NETCompact Framework, Silverlight and Mono.

The Framework Class Library (FCL) is a superset of the BCL classes and refers to the entire class library that ships with .NET Framework. It includes an expanded set of libraries, like Windows Forms, ADO.NET, ASP.Net, Language Integrated Query, Windows Presentation Foundation, Windows Communication Foundation among others. The FCL is much larger in scope than standard libraries for languages like C++, and comparable in scope to the standard libraries of Java.

Basically it helps to think of classes in the .NET Framework as bundles of related functionality. You access this functionality by creating a new instance of the class in the Base Class Library. Then you can access the Properties and Methods that are related to it.

Some classes though are known as Static Classes. They don’t require an instance to be created before can use them or access their properties and methods.

An example would be:

Let’s move on and have a look at how to create instances of classes in Silverlight applications. Therefore I created a new project in Visual Studio with just a button and a click event. But this time I did that in Xaml:

As you can see I have set some properties like the content, height, name, etc.

I want to create a new button, that is shown when I click the existing one. To do that I write some lines of code inside my click event handler on the xaml.cs page:

I created a new instance (new Button) of my class (Button) and set some properties. The result is:

Of course now I could add a click event to that new button to make it disappear when clicked. That’s not really the topic of this entry, but I did it anyway:

Eventually it needed to be added inside the other click event first:

 

To be continued…

Advertisements
%d bloggers like this: