Logo

dev-resources.site

for different kinds of informations.

CRUD operations on Arrays

Published at
1/7/2025
Categories
webdev
api
dotnetcore
csharp
Author
letsupdateskills
Categories
4 categories in total
webdev
open
api
open
dotnetcore
open
csharp
open
Author
16 person written this
letsupdateskills
open
CRUD operations on Arrays

Arrays in C# are fixed in size and do not have built-in methods for dynamic operations (like Add or Remove). However, you can perform CRUD operations by working with array elements.

1. Create Operation

You can initialize arrays with specific values or create an empty array and populate it later.

Example

// Creating an array with predefined values
int[] numbers = { 10, 20, 30 };

// Creating an empty array and assigning values later
int[] grades = new int[3];
grades[0] = 85;
grades[1] = 90;
grades[2] = 78;

Enter fullscreen mode Exit fullscreen mode

2. Read Operation

Access specific elements or iterate through the array.

Example

int[] numbers = { 10, 20, 30 };

// Accessing elements by index
Console.WriteLine(numbers[0]); // Output: 10

// Iterating through the array
foreach (var num in numbers)
{
    Console.WriteLine(num);
}

Enter fullscreen mode Exit fullscreen mode

3. Update Operation

Modify existing elements by accessing them via their index.

int[] numbers = { 10, 20, 30 };

// Updating the value at index 1
numbers[1] = 25;

foreach (var num in numbers)
{
    Console.WriteLine(num);
}
// Output: 10, 25, 30

Enter fullscreen mode Exit fullscreen mode

Please click here to see complete tutorial

dotnetcore Article's
30 articles in total
Favicon
.Net tarixi
Favicon
Oh bless me, Father, I have done something unholy: Installing .NET Core on Apple Silicon
Favicon
How to use Scoped service from Singleton Service in .Net Core
Favicon
How to add a Custom fields to Header in .NET Core Web API ?
Favicon
c#(.Net) - Basic Authentication WEB API
Favicon
CRUD operations on Arrays
Favicon
Working with interfaces
Favicon
Iterations
Favicon
Protfolio Website
Favicon
Dependency injection validation error in ASP.NET Core projects
Favicon
.Net Core and Kafka
Favicon
C# Null-Conditional (?.) & Null-Coalescing (??) Operators Explained
Favicon
Change a .Net Console application into an web application
Favicon
Efficient Bulk Operations with UkrGuru.Sql
Favicon
Improve Application Performance using β€œFire and Forget” in .NET Core
Favicon
API Versioning in .Net Core.
Favicon
Move objects from one folder to other in the same S3 Bucket using C# in AWS
Favicon
πŸŽ‰ We Made It: Trending in .NET on Dev.to! πŸš€
Favicon
.NET 9 Improvements for ASP.NET Core: Open API, Performance, and Tooling
Favicon
.Net Core Microservice Communication Using Kafka.
Favicon
Getting Started with .NET and Docker Tutorial
Favicon
Experimental attribute in C# is a powerful tool : Let's explore
Favicon
Implementing Chain of Responsibility Pattern in C# : Middleware's Design Pattern
Favicon
How to create a background email sender with outbox pattern integration
Favicon
The End of Microsoft's Monopoly on ASP.NET
Favicon
.NET Core MVC Project Structure : Implementing a Generic Service and Repository Pattern
Favicon
Did you know? How .NET Achieving Language Interoperability (C# + VB.NET = Same Application)
Favicon
These 10+ comparisons cover entire SQL concepts, Is it?
Favicon
NET 9 BinaryFormatter migration paths
Favicon
How to create a background email sender

Featured ones: