Asp.net dynamic two-dimensional array

Source: Internet
Author: User

I. arraylist stores two-dimensional arrays.

Why is arraylist used?
Arraylist is a dynamic array. It can declare and strengthen without knowing the length, and can be modified as needed.
State to increase the length, size, and delete any index content. These are not available in common arrays.

String [] get_num = new string [3]; // creates a cute array for your examples
Get_num [0] = "8, 5, 12, 12 ";
Get_num [1] = "82,52, 52,42 ";
Get_num [2] = "112,132 ";

Arraylist Al = new arraylist (); // declare and strengthen a silly arraylist
Arraylist Al = new arraylist (); // declare and strengthen a silly arraylist


For (INT I = 0; I <get_num.length; I ++)
{
String [] get_numarray = get_num [I]. Split (','); // cut the ordinary array according to ","
For (Int J = 0; j <get_numarray.length; j ++)
{

Al2.add (double) (double. parse (get_numarray [J]); // The default value of this example is the double class.
Type to add the second-dimensional content to Al 2.


}

Al. Add (double []) al2.toarray (typeof (double); // Add the content of the first dimension to Al
Al2.clear (); // clear the content to avoid the second-dimensional Accumulation

}


Double [] [] get_countnum = (double [] []) Al. toarray (typeof (double []); // OK! He's full, Al is transferred
Convert to a 2-dimensional array

 

 

Self-written

 

If (! Ispostback)
{
String [] A = Common. dealersrol (). Split (New char [] {','});
Arraylist Al = new arraylist ();
Arraylist Al = new arraylist ();
For (INT I = 0; I <A. length; I ++)
{
String [] B = A [I]. Split (New char [] {'| '});
For (Int J = 0; j <B. length; j ++)
{
Al2.add (string) B [J]);
}
Al. Add (string []) al2.toarray (typeof (string )));
Al2.clear ();
}
String [] [] C = (string [] []) Al. toarray (typeof (string []);
Dropdownlist1.datasource = C;
Dropdownlist1.databind ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.