> Chapter 1 - Introduction C# and .NET 6 - 3
AUTHOR: PID-1
TIMESTAMP: 2026-05-31 22:18:15
Understanding the .NET Runtime
Programmatically speaking, the term runtime can be understood as a collection of services that are required to execute a given compiled unit of code.Distinguishing Between Assembly, Namespace, and Type
To keep all the types within the base class libraries (bcls) well organized the .NET platform makes extensive use of the "namespace" concept. A namespace is grouping of semantically related types contained in an assembly or possibly spread across multiple related assemblies. For example, System.IO namespace contains file I/O related types. System.Data namespace defines basic database types, and so on.. 1) System : You find numerous useful types dealing with intrinsic data, mathematical computations, random number generation, environment variables, and garbage collection, as well as a number of commonly used exceptions and attributes. 2) System.Collections System.Collections.Generic : These namespaces define a number of stock container types, as well as base types and interfaces that allow you to build customized collections. 3) System.Data, System.Data.Common, These namespaces are used for interacting with relational databases using ADO.NET System.Data.SqlClient 4) System.IO, System.IO.Compression, These namespaces define numerous types used to work with file I/O, compression of data, and port manipulation. System.IO.Ports 5) System.Reflection, System.Reflection.Emit : These namespaces define types that support runtime type discovery as well as dynamic creation of types. 6) System.Runtime.InteropServices : This namespace provides facilities to allow .NET types to interact with unmanaged code (e.g. C-based DLLs and COM server) 7) System.Drawing, System.Windows.Forms : These namespaces define types used to build desktop applications using .NET's original UI toolkit (Windows Forms) 8) System.Windows System.Windows.Controls System.Windows.Shapes : The System.Windows namespace is the root for several namespaces that are used in WPF (Windows Presentation Foundation) applications. 9) System.Windows.Forms System.Drawing : The namespace System.Windows.Forms namespace is the root for several namespaces used in Windows Forms applications. 10) System.Linq System.Linq.Expressions : These namespaces define types used when programming against the LINQ API. 11) System.AspNetCore : This is one of many namespaces that allows you to build ASP.NET Core web applications and RESTful services. 12) System.Threading System.Threading.Tasks : These namespaces define numerous types to build multithreaded apps that can distribute workloads across multiple CPUs. 13) System.Security : Security is an integrated aspect of the .NET universe. In the security-centric namespaces, you find numerous types dealing with permissions, cryptography, etc. 14) System.Xml : The XML-Centric namespaces contain numerous types used to interact with XML data.Accessing a Namespace Programmatically
In C#, the using keyword simplifies the process of referencing types defined in a particular namespace.
using System;
Console.WriteLine("I'm learning C#");
Without the using statement;
using System;
Console.WriteLine("I'm learning C#");
While defining a type using the fully qualified name provides greater readability.
Global Using Statements (New 10.0)
Introduced C# 10, namespaces can be referenced globally and then be available in every file in the project automatically: • global using System; Note : All global using statements must come before any non-global using statements. A recommodation is that you place the global using statements along with your top level sttatement or a completely separate file (such as GlobalUsings.cs) or they can place in the project file for the application using the following format:
<ItemGroup>
<Using Include="System" />
</ItemGroup>
Implicit Global Using Statements (New 10.0)
The implicit global using statements supplied by .NET 6 varies based on the type of application you are building. Client (Microsoft.NET.Sdk) : • System • System.Collections.Generic • System.IO • System.Linq • System.Net.Http • System.Threading • System.Threading.Tasks Web (Microsoft.NET.Sdk.Web) : All from Microsoft.NET.SDK plus (+) • System.Net.Http.Json • Microsoft.AspNetCore.Builder • Microsoft.AspNetCore.Hosting • Microsoft.AspNetCore.Http • Microsoft.AspNetCore.Routing • Microsoft.Extensions.Configuration • Microsoft.Extensions.DependecyInjection • Microsoft.Extensions.Hosing • Microsoft.Extensions.Logging The vast majority of C#10 project templates enable global implicit using statements by default with the "ImplicitUsings" element in the project's main property group.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
To see the global using statements in your project, look for the:
File Scoped Namespaces (New 10.0)
Also new in C# 10, file-scoped namespaces remove the need to wrap your code in braces when placing it in a custom namespace.
namespace CalculatorExample {
public class Calculator {
}
}
Equals to
namespace CalculatorExample;
public class Calculator
{
}
Referencing External Assemblies
Prior versions of the .NET framework used a common installation location for framework libraries known as the GA (Global Assembly Cache) . When using Windows, each version of the runtime and SDK gets installed into "C:\Program Files\dotnet" Adding assemblies into most .NET projects is done by adding NuGet packages or referencing another project to the your project.Exploring an Assembly Using ildasm.exe
The Intermediate Language Disassembler (ildasm.exe) allows you to create a text document representing a .NET assembly and investigate its contents, including the associated manifest, CIL code, and type metada. This tool allows you to dive deeply into how the C# code maps to CIL and ultimately helps you understand the inner workings of the .NET platform.
"dotnet add package Microsoft.NETCore.ILDAsm --version 6.0.0"
https://www.nuget.org/packages/Microsoft.NETCore.ILDAsm/
CLI Command
Ildasm /all /METADA /out=csharp.il projectName.cs.dll