System Namespace
Overview
The System
namespace is the root namespace for fundamental classes in the .NET Framework. It provides base types, exception handling, and basic utilities that are essential for building applications.
Key Types
Class | Description |
---|---|
Object | Base class for all .NET types. |
String | Represents text as a series of Unicode characters. |
Exception | Base class for all exceptions. |
DateTime | Represents date and time. |
Math | Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions. |
Related Namespaces
- System.Collections – Interfaces and classes for collections.
- System.IO – Types that allow reading and writing to files and data streams.
- System.Text – Encoding, decoding, and string manipulation utilities.
- System.Linq – Language Integrated Query functionality.
- System.Net – Networking support.
- System.Threading – Concurrency and synchronization primitives.
Sample Code
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, .NET!");
int[] numbers = {1, 2, 3, 4, 5};
int sum = 0;
foreach (int n in numbers)
sum += n;
Console.WriteLine($"Sum: {sum}");
}
}