.NET Core API Reference
Explore the core libraries and frameworks for .NET Core development.
Introduction to .NET Core APIs
.NET Core provides a rich set of APIs to build modern, cross-platform applications. This reference documentation covers the fundamental namespaces and classes available.
The .NET Core API is organized into namespaces, which group related types (classes, structs, interfaces, enums, etc.). Understanding these namespaces is key to effectively using the framework.
Key Namespaces
The following are some of the most commonly used namespaces:
- System: The root namespace for fundamental types, including primitive data types, base classes, and mathematical functions.
- System.Collections.Generic: Provides interfaces and classes that define collections of objects, such as lists, queues, and dictionaries.
- System.IO: Contains types for reading and writing files, streams, and directories.
- System.Threading: Includes types that support multithreaded programming, allowing concurrent execution of tasks.
- System.Net.Http: Provides classes for sending and receiving HTTP requests and responses.
- System.Text: Contains classes for text manipulation, encoding, and decoding.
Discovering APIs
You can navigate through the API reference using the sidebar or by using the search functionality above.
Each API documentation page typically includes:
- Namespace and Type information.
- Member list (methods, properties, events).
- Detailed description of the type and its members.
- Syntax examples.
- Related API links.
Common API Patterns
Asynchronous Programming
.NET Core heavily leverages asynchronous programming patterns using async and await keywords, built upon the Task and Task<TResult> types found in System.Threading.Tasks.
// Example of an asynchronous method
public async Task<string> DownloadDataAsync(string url)
{
using (var httpClient = new HttpClient())
{
string content = await httpClient.GetStringAsync(url);
return content;
}
}
Dependency Injection
Built-in support for Dependency Injection (DI) is a cornerstone of .NET Core, managed via the Microsoft.Extensions.DependencyInjection namespace. It allows for flexible and testable application design.
Configuration
Configuration management is handled through the Microsoft.Extensions.Configuration namespace, supporting various sources like JSON files, environment variables, and command-line arguments.
Getting Started with API Exploration
To get the most out of the .NET Core API reference:
- Identify your needs: Determine what functionality you need (e.g., file operations, web requests, data structures).
- Navigate to the relevant namespace: Use the sidebar or search to find the namespace that likely contains the types you need.
- Explore types and members: Within a namespace, look for classes or interfaces that match your requirements. Examine their members for the specific methods or properties.
- Review examples: Code examples are crucial for understanding how to use APIs correctly.
Happy coding!