ASP.NET Array Application

xiaoxiao2021-04-03  246

String [] ABC = New String [8] {"1", "2", "3", "4", "1", "2", "3", "4"};

Response.write (Array.indexof (ABC, "3", 1)); // Find "3" in the ABC array, start from ABC [1]

Response.write (ARRAY.lastIndexof (ABC, "3")); // Find "3" in the ABC array, from the end

-------------------------------------------------- ----------------------------

String [] Arrstr = New String [8] {"1", "4", "3", "2", "16", "12", "14"}; // arrstr [0] = "1" ... arrstr [7] = "14"

Array.Reverse (arrstr); // reverse the Arrstr array, at this time, Arrstr [0] = "14" ... arrstr [7] = "1"

Array.Sort (arrstr); / / Sort by group, in this order is 1, 12, 14, 14, 16, 2, 3, 4 (because it is sorted by string)

-------------------------------------------------- ----------------------------

The Array type is redefined to define the size. It must be used in REDIM (VB). For large groups, it is particularly slow; and cannot be inserted in the middle; they cannot be cleared (only empty or 0)

ArrayList is slower than the Array, but does not need to be redefined, using myarrlist.add ("DOG") S can easily add data

ArrayList myarrlist = new arraylist (); // does not need to indicate the size of the array, and each element can be any data type;

Myarrlist.insert (1, "abc"); // Insert an element to an array [1]

Myarrlist.removeat (1); // Delete array elements [1]

myarrlist.remove ("abc"); // Delete content "ABC" array element, only delete it, if you want to delete, you need to do loops

-------------------------------------------------- ----------------------------

ListItem.Text = "a"; newItem.value = "b";

MyDropdown.Items.add (newItem); // Add item to the list box using ListItem

-------------------------------------------------- ----------------------------

Hashtable ht = new hashtable (); HT ["1"] = "a"; ht.add ("2", "a"); // HashTable Usage

SortedList Sl = new sortedlist (); SL ​​["1"] = "a"; sl. ADD ("2", "a"); // sortedList usage, automatically sort according to Key (DictionaryTry Abc in SL) // Traverse SortedList

-------------------------------------------------- ----------------------------

Connstr = @ "provider = microsoft.jet.Oledb.4.0; data source = c: /abc.mdb"; / / Connect Access database, pay attention to add a @

Connstr = "server = 127.0.0.1; database = myDatabase; uid = username; pwd = password"; / / Connect SQL Server database

Connstr = "provider = SQLOLEDB.1; server = 127.0.0.1; database = mydatabase; initial catalog = mycatalog; uid = username; pwd = password"; // Connect to SQL Server database with OLEDB

-------------------------------------------------- ----------------------------

Connstr = @ "provider = microsoft.jet.Oledb.4.0; data source = c: /abc.mdb"; / / Connect Access database, pay attention to add a @

OLEDBCONNECTION CON = New OLEDBCONNECTION (ConnTr); con.open (); conif.Close ();

or

OLEDBCONNECTION CON = New OLEDBCONNECTION ();

CON.CONNECTIONSTRING = connnectionstring = conve.open (); con.close ();

-------------------------------------------------- ----------------------------

OLEDBCONNECTION Con = New OLEDBCONNECTION (ConnTr);

OLEDBCOMMAND DC = New OLEDBCommand ("Select * from Employees", CON;

OLEDBDATAREADER DR = NULL; con. ipen (); dr = dc.executeReader ();

While (Dr.Read () == True) Response.write (DR ["firstname"] "
");

Dr.close () ;con.close (); // DataReader and Connection To close, Command is not

// This will not be used here, and .NET will be completed, but plus DR = NULL will release memory faster

-------------------------------------------------- ----------------------------

versus

):

1.TXTASP uses onclick, while TXTHTML uses ONSERVERCLICK

2.TXTASP uses text to set and get values, and txthtml uses TXTHTML.Value to set and get values.

3. is written using the inNerText property.

-------------------------------------------------- ----------------------------

Control:

ArrayList A = new arraylist (); for (int i = 0; i

No Rows and SelectionMode properties

RepeatColumns = 3 repeatdirection = "horizontal" or "vertical">

RepeatColumns = 3 repeatdirection = "horizontal" or "vertical">

List.selectedItem.text; list.selectedIndIndex; list.items [i] .selected;

List.Items.insert (0, New ListItem ("All", "-1"))

After adding the details Add, finally execute the following two sentences

SELECT_INFO.Items.Add ("Choose One Department");

SELECT_INFO.SELECTEDINDEX = SELECT_KC.Items.count-1;

转载请注明原文地址:https://www.9cbs.com/read-131550.html

New Post(0)