Share c# array

huongthien46

New member
#C ##Array #DatSource #Programming #tutorial ## C #mảng

** C# mảng **

Một mảng là một cấu trúc dữ liệu lưu trữ một tập hợp dữ liệu cùng loại.Trong C#, các mảng được khai báo bằng cú pháp sau:

`` `C#
int [] myarray = new int [10];
`` `

Điều này tạo ra một mảng gồm 10 số nguyên.Các phần tử của mảng có thể được truy cập bằng cú pháp sau:

`` `C#
MyArray [0] // Phần tử đầu tiên của mảng
myarray [9] // yếu tố cuối cùng của mảng
`` `

Mảng có thể được khởi tạo với các giá trị khi chúng được khai báo.Ví dụ: mã sau tạo một mảng gồm 10 số nguyên và khởi tạo từng phần tử thành giá trị 0:

`` `C#
int [] myArray = new int [10] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
`` `

Mảng cũng có thể được sử dụng để lưu trữ các đối tượng.Ví dụ: mã sau đây tạo ra một mảng 10 chuỗi:

`` `C#
Chuỗi [] myArray = chuỗi mới [10];
`` `

## hashtags

* #C#
* #Mảng
* #Cấu trúc dữ liệu
* #Programming
* #tutorial
=======================================
#C# #Array #datastructure #Programming #tutorial ##C# Array

**C# Array**

An array is a data structure that stores a collection of data of the same type. In C#, arrays are declared using the following syntax:

```c#
int[] myArray = new int[10];
```

This creates an array of 10 integers. The elements of the array can be accessed using the following syntax:

```c#
myArray[0] // The first element of the array
myArray[9] // The last element of the array
```

Arrays can be initialized with values when they are declared. For example, the following code creates an array of 10 integers, and initializes each element to the value 0:

```c#
int[] myArray = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
```

Arrays can also be used to store objects. For example, the following code creates an array of 10 strings:

```c#
string[] myArray = new string[10];
```

## Hashtags

* #C#
* #Array
* #datastructure
* #Programming
* #tutorial
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top