.NET Base Class Library (BCL)

The .NET Base Class Library (BCL) is a collection of fundamental types and classes that are available to all .NET developers. It provides a rich set of pre-built functionalities for common programming tasks, enabling rapid application development.

The BCL is organized into namespaces, which group related types and functionalities. Understanding the BCL is crucial for effectively leveraging the power of the .NET platform.

Key Features of the BCL

Commonly Used Namespaces

Some of the most frequently used BCL namespaces include:

Example: Working with Collections

Here's a simple example demonstrating the use of the List<T> generic collection:

using System;
using System.Collections.Generic;

public class Example
{
    public static void Main(string[] args)
    {
        List<string> fruits = new List<string>();
        fruits.Add("Apple");
        fruits.Add("Banana");
        fruits.Add("Cherry");

        Console.WriteLine("Fruits in the list:");
        foreach (string fruit in fruits)
        {
            Console.WriteLine($"- {fruit}");
        }

        Console.WriteLine($"\nTotal fruits: {fruits.Count}");
    }
}

Key Classes and Concepts

System.Object

public class Object

The ultimate base class for all types in the .NET Framework, providing default implementations for common operations.

System.String

public sealed class String

Represents a sequence of characters. Strings are immutable in .NET.

Common Methods:

string.Length: Gets the number of characters in the string.

string.Contains(string value): Determines whether the specified string contains a specified character.

string.ToUpper(): Converts the current string to uppercase.

System.Console

public static class Console

Represents the standard input, output, and error streams for console applications.

Common Methods:

Console.WriteLine(string value): Writes the specified string value to the standard output stream.

Console.ReadLine(): Reads the next line of characters from the standard input stream.

System.Exception

public class Exception

The base class for all exceptions in the .NET Framework. Used to signal errors.