1/45
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Delegate
A class in .NET that encapsulates a method.
Declaring and instantiating a delegate
The delegate keyword is used in declaring a delegate on a class.
new
To instantiate the delegate, use the 'new' keyword that is associated with the method.
Invoking Delegates
Invoking on referenced methods can also be done in delegates.
C#.NET
Events are usually task initiators. Clicking a mouse or pressing the Enter key are common events.
event
A member of a class that is fired whenever a specific action takes place.
event handlers
Methods invoked when an event occurs, registered through delegates.
Event Declaration
A delegate must be declared before declaring an event.
Event Accessors
Using the += operator allows adding an event to the class.
add accessor
To register a new subscription to an event.
remove accessor
To unregister the subscription.
collections
A group of objects including lists, linked lists, dictionaries, and arrays.
2 types of collections
Standard collections and Generic collections.
Standard collections
Collections found in the System.Collections namespace.
Generic collections
Collections found in the System.Collections.Generic namespace.
ArrayList
A collection class for an ordered collection of objects.
Hashtable
Stores key or value pairs, with the key representing the value.
SortedList
A combination of ArrayList and Hashtable that sorts key-value pairs.
Item
Gets and sets the value associated with a specific key in the SortedList.
void Add(object key, object value)
Adds an item with the specified key and value into the SortedList.
void Clear()
Removes all items in the SortedList.
bool ContainsValue(object value)
Returns true if the SortedList contains the specified value.
object GetByIndex(int index)
Returns the value at the specified index.
object GetKey(int index)
Returns the key at the specified index.
void Remove(object key)
Removes the element associated with the specified key from the SortedList.
void RemoveAt(int index)
Removes the element at the specified index from the SortedList.
Stack
Represents a LIFO collection of objects using push and pop operations.
Queue
Represents a FIFO collection of objects using enqueue and dequeue operations.
IEnumerable
An interface that allows looping through elements in a collection.
ICollection
An interface that allows determining the number of elements in a collection.
IDictionary
An interface that provides access to elements via a key or value.
Generics
Makes code reusable across different types by creating templates with placeholder types.
Generic Collections
Avoids the need for custom collections for each type in the application.
List<T>
A generic collection providing a dynamically allocated array for duplicate objects.
List<T> variableName = new List<T>();
Syntax for creating a List<T> collection.
Indexof()
Method used to check for a specified element in a list object.
Queue<T>
A generic collection representing a FIFO collection of objects.
Queue<int> ageQueue = new Queue<int>();
Syntax of the generic queue.
Enqueue()
Adds an element to the end of a queue.
Peek()
Returns the element at the beginning of the queue without removing it.
Dequeue()
Removes and returns the value at the beginning of the queue.
Stack<T>
A generic collection representing a LIFO collection of instances.
Stack<int> ageStack = new Stack<int>(20);
Syntax of the generic stack.
Push()
Adds an element at the top of the stack.
Peek()
Returns the element at the top of the stack without removing it.
Pop()
Removes and returns the value at the top of the stack.