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.
What is an assignment operation?
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.
Name the two important types used within the .NET Framework.
- Value Types
- Reference Types
What is the difference between value type, and reference type variables?
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.
Name the 2 sizes (in bits) of unicode characters?
- 16 bits
- 32 bits
Variable Declarations Summary
- 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.
-
Constant Declarations Summary
- 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.
Assignment Operators Summary
- 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)
What is the difference between simple and compound assignment operators?
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)
Ennumeration Summary
- 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.
What is an enumeration?
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.
Exception Handling Summary
- 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.
Exception Class Summary
- There are over 20 exceptions that the .NET Common Language Runtime can throw and that we can handle using the Exception Class.
-
Conversion Operations Summary
- 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.
Control Operations Summary
- 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.
String Operations Summary
- 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)