Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
76 Cards in this Set
- Front
- Back
What is a value type?
|
Variables that contain their data directly in the stack instad of containing a refererence to the data stored elsewhere in memory.
|
|
What are the three general value types?
|
Built-in types; User-defined types; Enumerations
|
|
What base type are all value types derived from?
|
System.ValueType
|
|
Describe System.SByte
|
1 Byte; Range: -128 to 127; Used for Signed byte values
|
|
Describe System.Byte
|
1 Byte; Range: 0 to 255; Used for Unsigned bytes
|
|
Describe System.Int16
|
Bytes:2; Range: -32768 to 32767; Used for Interoperation and other specialized uses;
|
|
Describe System.Int32
|
Bytes:4; Range: -2147483648 to 2147483647; Used for Whole numbers and counters.
|
|
Describe System.UInt32
|
Bytes:4; Range: 0 to 4294967295; Positive whole numbers and counters.
|
|
Describe System.Int64
|
Bytes:8; Range -9223372036854775808 to 9223372036854775807; Large whole numbers;
|
|
Describe System.Single
|
Bytes:4; -3.402823E+38 to 3.402823E+38; Floating point numbers
|
|
Describe System.Double
|
Bytes: 8; -1.79769313486232E+308 to 1.79769313486232E+308; Precise or large floating point numbers.
|
|
Describe System.Decimal
|
Bytes: 16; -79228162514264337593543950335 to 79228162514264337593543950335; Financial and scientific calculations requiring great precision.
|
|
What value types does the runtime optimize performance for?
|
Int32, UInt32 and Double.
|
|
Describe System.Char
|
Bytes:2; Single Unicode characters
|
|
Describe System.Boolean
|
Bytes:4; True/False Values
|
|
Describe System.IntPtr
|
Size: Platform dependent; Pointer to a memory address.
|
|
Describe System.DateTime
|
Size: 8 bytes; 1/1/0001 12:00:00 AM to 12/31/9999 11:59:59 PM; Moments in time.
|
|
What are all types derived from?
|
System.Object
|
|
What should you declare a variable as if you want to be able to determine whether a value has been assigned or not?
|
Nullable
|
|
Give an example of declaring a variable a nullable.
|
Dim b as Nullable(Of Boolean) = Nothing
Nullable<bool> b = null; bool? b = null; |
|
Declaring a variable as nullable enables which members?
|
HasValue and Value
|
|
How do you detect whether or not a value has been set for a Nullable type?
|
Use HasValue.
|
|
Give an example of using HasValue and Value members for checking a Nullable type.
|
If b.HasValue Then Console.WriteLine("b is {0}.", b.Value) Else Console.WriteLine("b is not set.")
if (b.HasValue)Console.WriteLine("b is {0}.", b.Value); else Console.WriteLine("b is not set."); |
|
What is another term for User-defined types?
|
Structures
|
|
Where are structures stored?
|
On the stack.
|
|
What type is System.Drawing.Point?
|
Value-Type; User-defined Type; structure.
|
|
Structure types should meet the following criteria...
|
Logically represent a single value; Has and instance size less than 16 bytes; Will not be changed after creation; Will not be cast to a reference type.
|
|
Give an example of declaring an enumeration>
|
Enum Titles As Integer
Mr Ms Mrs Dr End Enum enum Titles : int{Mr, Ms, Mrs, Dr}; |
|
Reference types store the address of thier data, also known as a pointer where?
|
On the stack.
|
|
The actual data that is stored for a reference type is stored where?
|
On the heap.
|
|
The runtime manages the memory used by the heap how?
|
By a prcoess called "Garbage Collection"
|
|
What does Garbage Collection do?
|
Recovers memory periodically as needed by disposing of items that are no longer referenced.
|
|
When does Garbage Collection occur?
|
When needed or triggered by a call to GC.Collect.
|
|
What happens when you assign a reference type to another instance of that reference type?
|
Both instances will point to the same memory location on the heap.
|
|
Everything not derived from System.ValueType is what?
|
A reference type.
|
|
Describe System.Object
|
Can convert any type to System.Object. Most general type in the Framework.
|
|
Describe System.String
|
Text Data
|
|
Describe System.Text.StringBuilder
|
Dynamic text data
|
|
Describe System.Array
|
Base class for all arrays. Arrays of data.
|
|
Describe System.IO.Stream
|
Buffer for file, device and network I/O. Abstract base class; task-specific classes are derived from Stream.
|
|
Describe System.Exception
|
Task-specific exceptions inherit from this type.
|
|
What does immutable mean?
|
Any change causes the runtine to create a new object and abandon the old one.
|
|
Is System.String immutable?
|
Yes
|
|
What happens when you append strings using + ?
|
Only the last string has a reference, all others will be disposed during garbage collection
|
|
How do you avoid temporary strings?
|
Use the Concat, Join or Format methods to join multiple items in a single statement or use the StringBuilder class.
|
|
The default constructor for StringBuilder creates a buffer size of how long?
|
16 bytes
|
|
Describe FileStream
|
Create a base stream used to write to or read from a file.
|
|
Describe MemoryStream
|
Create a base stream used to write to or read from memory.
|
|
Describe StreamReader
|
Read data from the stream
|
|
Describe StreamWriter
|
Write data to the stream
|
|
How should you order your catch blocks for Exception handling?
|
From most specific to the more generic.
|
|
From what class should you derive from when defining your own exceptions?
|
System.ApplicationException
|
|
What should be done in the finally block for Exception handling?
|
closing streams or cleaning up any objects that might be left open if an exception occurs.
|
|
What is an interface?
|
A contract, defines a common set of members that all classes that implement the interface must provide.
|
|
Describe IComparable
|
Implemented by types whose values can be ordered (numeric and string classes). IComparable is required for sorting.
|
|
Describe IDisposible
|
Defines methods for manually disposing of an object.
|
|
Describe IConvertible
|
Enables a class to be converted to a base type such as Boolean, Byte, Double or String.
|
|
Describe ICloneable
|
Support copying an objectg
|
|
Describe IEquatable
|
Allows you to compare to instances of a class for equality. (a==b)
|
|
Describe IFormattable
|
Enables you to convert the value of an object into a specially formatted string. Provides more flexibility than the base ToString method.
|
|
Can a class implement multiple interfaces?
|
Yes
|
|
Can a class be inherited from multiple classes in .Net?
|
No
|
|
What are partial classes?
|
Allow you to split a class definition across multiple source files. It hides details of the class definition so that derived classes can focus on more significant portions.
|
|
What are generics?
|
Allows a user to define a type while leaving some details unspecified. Instead of specifying the types of parameters or member classes, you can all code that uses your type to specify it.
|
|
What are the advantages of using generics?
|
Reduced run-time errors and improved performance.
|
|
Give an example of creating a Generic Type.
|
class Gen<T, U>{public T t; public U u;
public Gen(T _t, U _u) { t = _t; u=_u; } } |
|
What is the significant limitation of creating a generic class?
|
generic code is only valid if it will compile for every possible constructed instanc of the generic, whether an Int, a string, or any other class.
|
|
Give an example of consuming a generic type
|
Gen<string, string> ga = new Gen <string, string>("Hello, ", "World!");
|
|
How do you avoid the limitation of generics of having to write code that would compile for any class?
|
Use constraints to place requirements on the types that consuming code can substitute for your generic.
|
|
What are the four types of constraints Generics support?
|
Interface - Allow only types that implement specific interfaces to use your generic.
Base Class - Allow only types that match or inherit from a specific base class to use your generic. Constructor - Require types that use your generic to implement a parameterless constructor. Reference or value type - Require types that use your generic to be either a reference or value type. |
|
What do you use to apply a constraint to a generic?
|
As clause in VB and Where clause in C#
|
|
What is an event?
|
A message sent by an object to signal the occurrence of an action.
|
|
What is the object that raises an event called?
|
Event sender
|
|
What is the object that captures an event and responds to an event called?
|
Event receiver.
|
|
What is a delegate?
|
Holds a reference to a method. It is a function pointer or a callback.
|
|
Give an example of an event delegate declaration.
|
public delegate void AlarmEventHandler(object sender, EventArgs e);
|