Get started with .NET Libraries
There’s more to building a C# application than stringing together lines of code. You’ll need the .NET Runtime, which hosts and manages your code as it executes on the end user’s computer. You’ll also rely on the .NET Class Library, a prewritten collection of coding resources that you can use in your applications. This unit explains what the .NET Class Library is and how it complements the C# programming language.
What is the .NET Class Library?
When you need to find a book, a public library is a good place to look. After all, libraries contain thousands and thousands of books, and they’re organized into sections that help you to find what you’re looking for. When you need to implement a programming task, the .NET Class Library is a good place to look, because it’s an organized collection of programming resources.
The .NET Class Library is a collection of thousands of classes containing tens of thousands of methods. For example, the .NET Class Library includes the Console
class for developers working on console applications. The Console
class includes methods for input and output operations such as Write()
, WriteLine()
, Read()
, ReadLine()
, and many others. For example, you may already be familiar with the following code:
C#Copy
Console.WriteLine("Hello, World!")
You can think of a class as a container for methods, kind of like the sections of the public library. Developers typically keep related methods together in a single class. As you saw in the previous example, any methods that can send or receive information from a console window are collected into the System.Console
class in the .NET Class Library.
In many cases, these classes and methods enable you to build a specific type of application. For example, one of the larger subsets of classes and methods enable you to create dynamic web applications. There’s also several families of classes that enable you to build native desktop applications. Another subset of classes and methods enable you to access a database. There are lots of classes in the .NET Class Library that support specific types of applications.
There are other classes with methods that provide support in a more general way. In other words, their utility spans a wide range of device platforms, application frameworks, and technology areas. For example, if you want to read or write file information, or perform trigonometry or calculus operations, there are general purpose classes that you can use in your code. It doesn’t matter whether you’re building applications for the web, desktop, mobile device, or the cloud, general purpose classes and methods are there to help.
As you can imagine, having a massive library of functionality available to your applications is a huge time saver for you as a software developer. The classes and methods in the .NET Class Library are created by Microsoft and are available for use in your applications.