Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the operations of C # array?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the operations of the C # array". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "what are the operations of the C # array?"

C # array operation

1. An array is a finite sequence of n (n ≥ 1) data elements of the same data type.

two。 Have a fixed format and quantity

3. Each data element is identified and accessed by a * subscript.

4. Once defined, the size and upper and lower bounds of each dimension cannot be changed, so operations such as inserting and deleting data elements cannot be carried out on the array.

5. The array uses a sequential storage structure to store the data elements in the array.

6. The operations on the array generally include:

◆ value operation: given a set of subscripts, read the corresponding data elements

◆ assignment operation: stores or modifies the corresponding data elements given a set of subscripts

◆ cleanup operation: clears all data elements in the array

◆ copy operation: assigns data elements from one array to another

◆ sort operation: sorts the data elements in the array, which requires the data elements in the array to be sortable

◆ reverse operation: reverses the order of data elements in an array.

Array in C #

1.C# supports one-dimensional arrays, multidimensional arrays, and interlaced arrays.

two。 All array types implicitly inherit from System.Array.

3.Array is an abstract class that inherits from System.Object,ICloneable, IList, ICollection, IEnumerable, so the array is a reference type.

In addition to creating static arrays, 4.C# can also create dynamic arrays by using Array's static method CreateInstance method.

C # array operation program code:

Public class myArray {public void Run () {/ / static array string [] arr = new string [5]; for (int I = 0; I < 5; iDiplus +) {arr [I] = "val" + I;} / / dynamic array Array arr1 = Array.CreateInstance (typeof (string), 5); for (int I = 0; I < 5; iSum +) {arr1.SetValue ("val" + I, I) } / / output Console.WriteLine ("- arr-"); foreach (string i in arr) {Console.WriteLine (I);} Console.WriteLine ("- arr1-"); foreach (string i in arr1) {Console.WriteLine (I) At this point, I believe you have a deeper understanding of "what is the operation of the C# array". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report