C# Flashcards
(224 cards)
What is a variable?
~ storage location in memory (RAM) that a programmer can use to store data
What parts does a variable have? (5)
- identifiers: labels to refer to storage location
- scope: availability of data while program executes / in scope if still in memory
- address: actual location in RAM
- data type: defines storage and proper use of data
- value: actual data that is stored in variable
List the 5 different .NET data types.
integer
floating-point
boolean
char
built-in reference
What are the 2 subtypes of .NET built-in reference data types?
string and object
List the 8 different .NET integer data types with their respective Visual C# name.
- System.Byte - byte
- System.Int16 - short
- System.Int32 - int
- System.Int64 - long
- System.SByte - sbyte
- System.UInt16 - ushort
- System.UInt32 - uint
- System.UInt64 - ulong
C# byte data type
8 bit, unsigned, 0 to 255
Give description (sign and storage) and range of the C# short data type.
signed, 16 bit, -32768 to 32767
Give description (sign and storage) and range of the C# int data type.
32 bit, signed, -2^31 to 2^31-1
Give description (sign and storage) and range of the C# long data type.
64 bit, signed, -2^63 to 2^63-1
Give description (sign and storage) and range of the C# sbyte data type.
8 bit, signed, -128 to 127
Give description (sign and storage) and range of the C# ushort data type.
16 bit, unsigned, 0 to 65535
Give description (sign and storage) and range of the C# uint data type.
unsigned, 32 bit, 0 to 2^32-1
Give description (sign and storage) and range of the C# ulong data type.
64 bit, unsigned, 0 to2^64-1
List the 3 floating point data types with their type name and their C# name.
- System.Single - float
- System.Double - double
- System.Decimal - decimal
Give description, precision and range of the float floating point data type.
- 32 bit - 7 significant digits - +/-1.4 x 10^-45 to +/-3.4 x 10^38
Give description, precision and range of the double floating point data type.
- 64 bit - 15 - 16 sign. digits - +/-5.0 x 10^-324 to +/-1.7 x 10^308
Give description, precision and range of the decimal floating point data type.
- 128 bit - 28 sign. digits - +/-1.0 x 10^-28 to +/-7.9 x 10^28
What is the System.Boolean type called in C#?
bool
What values can Boolean take on?
only true and false
What is the System.Char called in C# and what does it represent?
Char and it represents a single 16-bit Unicode character by enclosing it in single quotes.
What is the use of a string data type?
You can assign a series of char data, e.g. a word or a paragraph, to a string variable.
What difference is there between the assignment of a char literal in contrast to a string literal.
- Char values are enclosed in single quotes.
- String values are enclosed in double quotes.
What type of data can you assign to System.object?
It is the super type. All others derive from it and you can assign any object or value to it.
How do you assign an object to the object type?
object myObject;
myObject = 543
myObject = new System.Windows.Forms.Form()