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

How to implement C # interlaced array

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people don't understand the knowledge points of this article, so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to achieve C# staggered array" article.

Staggered array: the array element itself is an array

Public static void Main (string [] args) {

Int [] [] arr = new int [5] []; arr [0] = new int [8]

Arr [1] = new int [8]; arr [2] = new int [8]

Arr [3] = new int [8]; arr [4] = new int [8]

Random rdm = new Random ()

For (int I = 0; I < arr.Length; iTunes +) {

For (int j = 0; j < 8; jacks +) {arr [I] [j] = rdm.Next (31);}}

Foreach (int [] an in arr) {foreach (int b in a)

{Console.Write ("{0},", b)

}

Console.WriteLine ("")

}

}

To put it simply: explain the first on the left, the first [] on the left, the first table on the left, the second on the left means that the one-dimensional array itself is also an one-dimensional array. The first on the right represents the length, and the second on the right means that a large array contains five small arrays.

Let's NEW a random number first.

The length of the cyclic interlaced array at the first layer.

The second layer loop is used to access the elements of the decimal array. For the outer loop, the second layer represents the j element of the large element of a [I] I, an array element.

The I small element of the I big element in the loop is then generated by a random number.

Use two for each

B is an element in a. B is also an array of dimensions.

Give a for each for element B

And then print.

The above is the content of this article on "how to realize the interleaving array of C #". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

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