C# Programming Flashcards

In this chapter, we will begin by looking at types. We will then describe how to declare variables and constants in C#. Next, we will discuss the different types of assignment operators—simple and compound—and how they are used. After that, we will look at enumerations. And finally, we will discuss exception handling.

1
Q

What is an assignment operation?

A

An assignment operator sets the value of a variable, constant, or other item in the code behind of a Page class.

The assignment statement is so fundamental to computer programming that every procedural/imperative programming language requires such a statement—regardless of its syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name the two important types used within the .NET Framework.

A
  • Value Types
  • Reference Types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between value type, and reference type variables?

A

A variable of value type contains an instance of the type and has a set memory size.

A reference type contains a pointer (or a reference) to an instance of a type which does not have an allocated memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name the 2 sizes (in bits) of unicode characters?

A
  • 16 bits
  • 32 bits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Variable Declarations Summary

A
  • To declare a variable, its type must be explicitly defined, and it must be given a name.
  • C# will give new variables a default value, however it is beter to explicitly define a starting value.

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Constant Declarations Summary

A
  • A constant is a fixed value that cannot be modified during the execution of a program.
  • Can be both value and reference type.
  • To declare a constant, we specifically use the word const.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Assignment Operators Summary

A
  • Simple assignment operators store a value with no calculation to change the value. X = Y
  • Compound assignment operators store a value but perform a calculation which will alter the initial value. X += Y (Equivalent to X = X + Y)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the difference between simple and compound assignment operators?

A

Simple assignment operators store a value (X = Y) whereas compound assignment operators store a value before/after performing some calculation on the value.

(X += Y Equivalent to X = X + Y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Ennumeration Summary

A
  • An ennumeration is a set of named constants of a specific type.
  • You use an enumeration type to represent a choice from a set of mutually exclusive values or a combination of choices.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an enumeration?

A

An ennumeration is a set of constants of a specific type.

They provide a way to declare and use a set of relatable constants that can be assignmed to a variable in the code behind.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Exception Handling Summary

A
  • An exception occurs in response to a runtime error. (an error that occurs during the execution of a computer program.
  • Exception handling allows us to deal with errors gracefully instead of having an application crash.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Exception Class Summary

A
  • There are over 20 exceptions that the .NET Common Language Runtime can throw and that we can handle using the Exception Class.

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Conversion Operations Summary

A
  • A conversion operation alters the value of one type so that it can be ised in a variable of another type.
  • Can be Widening or Narrowing conversions.
  • Widening conversions always preserve the value of the source variable as the target variable can fully accomadate the possible range of values of the source variable.
  • Narrowing conversions must be performed when the target type cannot accomadate the value of the source variable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Control Operations Summary

A
  • Decision Operations ater the path of a programs execution based on the result of a logical operation.
  • Iterative Operations execute a block of code repeatedly while a condition is met.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

String Operations Summary

A
  • A string operation is a process that is performed on a string object.
  • A string is a type that has been instantiated from the string class. (Usually a sequence of characters that are meant to be “read” as written)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an escape character?

A

An escape character is a character that changes the meaning of the character (or characters) that follow it within a string.

17
Q

What is a verbatim literal?

A

Verbatim literals in C# can be used to write out a string “word for word”. They (almost) negate the need for escape sequences.

18
Q

What is an array?

A

An array is a container that holds data while it is being manipulated by a computer program.
It is a data structure that consists of a collection of elements of the same type, where each element contains its own value and is identified by one or more indices.

19
Q

What is a stack?

A

A stack is a one-dimensional last-in-first-out (LIFO) data structure that contains zero or more objects.

Operations on the stack can only occur at the top of the stack.

20
Q

What is a queue?

A

A queue is a one dimensional first-in-first-out (FIFO) data structure that contains zero or more objects.

Operations on a queue can only occur at the beggninig of a queue. (the object that joined the queue first)

21
Q

Collection Operations Summary

A
  • A collection is a container that holds data while it is being manipulated by a computer program. More specifically, it is a data structure that consists of \ero or more items where each item contains its own value or values.
  • Some examples include: Stacks, Queues, Linked Lists and Sorted Lists.
22
Q

File System Operations Summary

A
  • A file system defines how a computers data is structured.
  • When developing Web applications, we often encounter the need to interact with the Web server’s file system to perform such operations.
  • The File class permits us to do such things as create/read/write from files, and get or set properties of files.
23
Q

Class Design Summary

A
  • Class design is the process of planning the properties, methods, and events of a class.
  • Classes should be designed with reusability in mind.
  • A high degree of cohesion should be sought.
  • A low degree of coupling should also be sought.
24
Q
A