Event Driven - Prelim

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/75

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

76 Terms

1
New cards

Delegates

A class in .NET that encapsulates a method and holds a reference to a method.

2
New cards

delegate keyword

Used in declaring a delegate on a class.

3
New cards

Syntax for Delegate Declaration

delegate ()
4
New cards

Instantiation of Delegate

Use the new keyword associated with the method to create an instance.

5
New cards

Generic Delegates

Delegates that are not bound to any specific type and can reference methods of different types.

6
New cards

Difference between Delegate and Interface

Delegates have no implementation, while interfaces can implement methods.

7
New cards

Event

A member of a class that is fired whenever a specific action takes place.

8
New cards

Event Handlers

Methods that are invoked when an event occurs.

9
New cards

Adding an Event

Use the syntax eventname += delegateinstance.

10
New cards

Removing Event Subscription

Use the remove accessor to unregister a subscription.

11
New cards

Collections

Groups of objects that include lists, linked lists, dictionaries, and arrays.

12
New cards

Standard Collections

Found in the System.Collections namespace.

13
New cards

Generic Collections

Found in the System.Collections.Generic namespace.

14
New cards

ArrayList

A collection class known for an ordered collection of objects that is dynamic.

15
New cards

Hashtable

Stores key-value pairs where the key represents the value in the collection.

16
New cards

SortedList

A combination of ArrayList and Hashtable that stores key-value pairs sorted by key.

17
New cards

Capacity (SortedList)

Gets or sets the capacity of the SortedList.

18
New cards

Count (SortedList)

Gets the count of the number of elements in the SortedList.

19
New cards

Item (SortedList)

Gets and sets the value associated with a specific key in the SortedList.

20
New cards

Keys (SortedList)

Holds the keys in the SortedList.

21
New cards

Values (SortedList)

Holds the values in the SortedList.

22
New cards

Add method (SortedList)

Adds an item with the specified key and value into the SortedList.

23
New cards

Clear method (SortedList)

Removes all the items in the SortedList.

24
New cards

ContainsKey method (SortedList)

Returns true if the SortedList contains the specified key.

25
New cards

ContainsValue method (SortedList)

Returns true if the SortedList contains the specified value.

26
New cards

GetByIndex method (SortedList)

Returns the value of the specified index.

27
New cards

GetKey method (SortedList)

Returns the key of the specified index.

28
New cards

Remove method (SortedList)

Removes the element with the specified key from the SortedList.

29
New cards

RemoveAt method (SortedList)

Removes an element at the specified index in the SortedList.

30
New cards

Stack

Represents a Last In, First Out (LIFO) collection of objects.

31
New cards

Queue

Represents a First In, First Out (FIFO) collection of objects.

32
New cards

IEnumerable interface

Allows looping through elements in a collection.

33
New cards

ICollection interface

Determines the number of elements in a collection and can copy them into an array.

34
New cards

IDictionary interface

Provides a list of elements accessible via a key or value.

35
New cards

Generics

Allows code reuse across different types by creating a template with placeholder types.

36
New cards

System.Collections.Generic namespace

Contains several generic collection classes.

37
New cards

List

A generic collection that provides an efficient and dynamically allocated array.

38
New cards

Add() method (List)

Adds items to the end of a list.

39
New cards

Remove() method (List)

Removes the specified item from the list.

40
New cards

IndexOf() method (List)

Checks for the specified element and returns its index value.

41
New cards

Sort() method (List)

Sorts elements in the list.

42
New cards

Queue

A generic collection representing a FIFO collection of objects.

43
New cards

Enqueue() method (Queue)

Adds an element to the end of the queue.

44
New cards

Peek() method (Queue)

Returns the element at the beginning of the queue without removing it.

45
New cards

Dequeue() method (Queue)

Removes and returns the value at the beginning of the queue.

46
New cards

Stack

A generic collection that represents a LIFO collection of instances.

47
New cards

Push() method (Stack)

Adds an element at the top of the stack.

48
New cards

Peek() method (Stack)

Returns the element at the top of the stack without removing it.

49
New cards

Pop() method (Stack)

Removes and returns the value at the top of the stack.

50
New cards

Difference: Delegate Implementation

Delegates have no implementation while interfaces can implement methods associated with them.

51
New cards

Usage of Delegates

Used in classes where multiple implementations of methods are needed.

52
New cards

Performance of Delegates vs Interfaces

Delegates are faster to execute but slower to acquire, interfaces are slower to execute but faster to acquire.

53
New cards

Subscription to Events

Registered using add accessor for events.

54
New cards

Removing Subscriptions to Events

Done using the remove accessor associated with the event.

55
New cards

ArrayList vs Static Array

ArrayList is dynamic; a static array has a fixed size.

56
New cards

Hashtable Key Requirement

Keys must be specified to access corresponding values in Hashtable.

57
New cards

SortedList Access Requirements

Key or index value must be specified to access values in SortedList.

58
New cards

SortedList Method: Add

Adds a key-value pair to the SortedList.

59
New cards

SortedList Method: RemoveAt

Specifies index to remove the element in the SortedList.

60
New cards

Stack Behavior

LIFO, utilizing push and pop operations.

61
New cards

Queue Characteristics

FIFO, utilizing enqueue and dequeue operations.

62
New cards

IEnumerable Functionality

Provides iteration capabilities for collections.

63
New cards

Generics Purpose

To enhance code reusability by specifying data types at runtime.

64
New cards

List Capacity

Can dynamically grow or shrink based on object quantity.

65
New cards

Generic Method Example: Add() in List

nameOfStud.Add("Rose"); to add a student.

66
New cards

Generic Method Example: Remove() in List

nameOfStud.Remove("Mike"); to remove a specified student.

67
New cards

Generic Method Example: IndexOf() in List

Console.WriteLine(nameOfStud.IndexOf("Rose")); to find index.

68
New cards

Generic Method Example: Sort() in List

nameOfStud.Sort(); to sort the student names.

69
New cards

Queue Object Example

Queue ageQueue = new Queue(); to create a queue of integers.

70
New cards

Queue Method Example: Enqueue()

ageQueue.Enqueue(18); to add an age to the queue.

71
New cards

Queue Method Example: Peek()

ageQueue.Peek(); to get the first age without removing.

72
New cards

Queue Method Example: Dequeue()

int getValue = ageQueue.Dequeue(); to remove and get the first age.

73
New cards

Stack Object Example

Stack ageStack = new Stack(20); to create a stack.

74
New cards

Stack Method Example: Push()

ageStack.Push(18); to add age to the top of the stack.

75
New cards

Stack Method Example: Peek()

int getValue = ageStack.Peek(); to get the top age without removing.

76
New cards

Stack Method Example: Pop()

int getValue = ageStack.Pop(); to remove and get the top age.