Elementary School Student C #,
I. go deep into C # Data Types
Value Type transfer and reference type transfer
The parameters of the method are value type and reference type.
Note: There is no ref for passing values or passing references.
01. If the parameter type of the method itself is the reference type, modifications to the parameter value will be permanently saved
Example: public void TP (SE se)
{
Se. Count ++; // modify the Count value of the se object.
}
02. If the parameter type of the method itself is a value type without ref modification, modifications to the parameter value will not be permanently saved ()
03. If the parameter type of the method itself is a value type, but it has ref modification, the modification of the object parameter value will also be permanently saved.
Value Type transfer: parameter transfer without ref
Reference Type transfer: Passing parameters with ref
The instance (Manager rating) is as follows:
The key code is as follows:
Ii. Use a set to organize relevant data
1. Introduction of the Set Concept
Set: some specified object sets are set together.
The following is a set of Hello Kitty
Array: a container that can store a pile of data of the same data type
3. Set element operations (ADD, traverse, delete, and Common Errors)
3. common attributes:
Capacity: space occupied by the set
Count: number of elements stored in the Set
4. Common Methods:
Add: int Add (Object value) // Add an Object to the end of the Set
Traversal: traversing through foreach
Delete: Remove (), RemoveAt (), and Clear ()
*: Note: if an element in the set is deleted, the index of the set is automatically maintained.
Remove (): Delete content
RemoveAt (): deletes an index.
Clear (): removes all elements from the set at a time.
Contains (): whether to include an element
5. Set Initiator
ArrayList engineers = new ArrayList ()
{
New SE () {Name = "", Age = 26,
Gender = Gender. male, ID = "000", Popularity = 10 },
New SE () {Name = "", Age = 22,
Gender = Gender. female, ID = "111", Popularity = 20 },
New SE () {Name = "", Age = 30,
Gender = Gender. male, ID = "222", Popularity = 20}
};
6. HashTable
Hashtable is usually called a hash table.
You can find the corresponding Value based on the Key)
★1. HashTable considerations
01. HashTable collections can only be traversed cyclically using foreach
02. Elements in the HashTable set are unordered (the element content is not displayed in the order of Add)
03. Duplicate keys in HashTable
04HashTabel no RemoveAt ()
★2. Three Methods for HashTable traversal:
☆: The first method is to traverse all the keys and obtain the value through the key value.
☆: Method 2: traverse all value Sets
☆: Method 3: traverse both key and value
Eg:
Foreach (DictionaryEntry item in table)
{
Console. WriteLine (item. Key + "value =" + item. Value );
}
7. Generic set List <T>
Generic: A New set type is created to constrain the element type in ArrayList. This type can only contain multiple elements of the same type, identifier <T>, it can be seen as a placeholder, and the generic type is to advance the runtime error to the Compilation Time
8. Generic set Dictionary <K, V>
Dictionary <string, Person> dic = new Dictionary <string, Person> ();
The instance (employee sign-in) is as follows:
The key code is as follows:
Knowledge summary project ():
The key code is as follows: