Asp.net class/object/structure/method/function/attribute/array

Source: Internet
Author: User

Asp tutorial. net class/object/structure/method/function/attribute/array
Namespace arraylist2
{
Class program
{
Static void main (string [] args)
{
// The clear, remove, removeat, and removerange methods of the arraylist are listed below.
Int [] arr = new int [9] {1, 2, 3, 5, 6, 7, 89, 12,120 };
Arraylist list = new arraylist (arr );
Console. writeline ("original arraylist set :");
Foreach (int I in list)
Console. write (I + "");
Console. writeline ();
Console. writeline (list. contains (2); // You can check whether the set contains array 2.
List. remove (5); // delete a set containing 5 values

Foreach (int I in list)
Console. write (I + "");
Console. writeline ();
List. removeat (1); // delete the value at the position where the index is 1

Foreach (int I in list)
Console. write (I + "");
Console. writeline ();
List. removerange (5, 2); // delete two elements from the position where the index is 5

Foreach (int I in list)
Console. write (I + "");
Console. writeline ();
Console. writeline (list. contains (2 ));
List. clear (); // clear all elements in the set

Foreach (int I in list)
Console. write (I + "");
Console. writeline ();

Console. readkey ();

}
}
}


In my understanding, a class is an abstract object set that combines the same features of an object.

A structure is a value type used to encapsulate a group of related variables. It is similar to a class, but has more restrictions and does not support inheritance (class supports single inheritance)

Classes and structures can contain -- attributes and methods (attributes are generally defined by get-set accessors. Methods and functions are the same. Static methods [cannot operate on specific instances] cannot be accessed using this, non-static

One-dimensional array, two-dimensional array (the first matrix can be easily understood)

One-dimensional array length calculation: arr. length two-dimensional: row = arr. rank column = arr. getupperbound (arr. rank-1) + 1

Arraylist, with a powerful number, why do we still need arraylist?

1: arraylist can automatically expand the capacity, and the array is fixed

2: arraylist can add, delete, and insert a range of methods, arrays can only be a single operation

3: arraylist provides a method to return read-only and fixed-size packages to a set. Arrays cannot

Disadvantage: arraylist can only be one-dimensional

My personal feeling: the complementary arraylist and array cannot be replaced. To use arraylist, you need to call the system. collections namespace.

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.