Chapter 2 : Data Processing Flashcards
1
Q
Describe TextBox control ( 5 )
A
- Rectangular area
- Can accept keyboard input from the user
- Locates in the common control group of the toolbox
- Default name is textBoxn( n = 1 , 2 , 3 … )
- Double click to add it to the form
2
Q
What property does TextBox controls?
A
- Text property which stores user inputs
- Only accepts string values
textBox1.Text = “Hello”;
Clear TextBox control content
textBox1.Text=””
3
Q
How to declare variable in C#?
A
- DataType VariableName;
String text
double currency_rate
- Variable is a storage location in memory
4
Q
What are the bytes used in int, float and double?
A
- int - 4 bytes
- float - 4 bytes
- double - 8 bytes
5
Q
What is char used for?
A
- Storing a single character
- String is a collection of character
6
Q
What is most data type known as?
A
- Primitive data types
7
Q
Ways to use variables ( 3 )
A
- Store value
product = “Mac Book” - Assign to another value
productLabel.Text = product - Display in a message box
MessageBox/.Show(product)
8
Q
What does a local variable belongs to?
A
- Method which it was declared
- Only statements inside that method can access the variable
9
Q
What is the lifetime of a variable?
A
- Time period during which the variable exists in memory while the program is executing
10
Q
List out the rules of variables ( 4 )
A
- Can assign a value only if the value is compatible with the variable’s data type
- A variable holds one value at a time
- Variable must be assigned before it can be used, I can initialize the variable with a value when declare it
- Multiple variables with the same type may be declared with one statement
11
Q
Can the value of int and double surrounded by quotes?
A
- no
12
Q
What does the decimal data type indicates?
A
- 128 bit data type
13
Q
What is the advantages of decimal compared to double
A
- Makes appropriate for financial and monetary calculation since it has more precision and smaller range
14
Q
How to declare decimal data type?
A
- decimal payRate = 28.5m
- decimal price = 8.95M
- Need to add the letter M ( or m ) to a decimal value
15
Q
How to type casting?
A
- Use a cast operator with parentheses with the type keyword
( type )
wholeNumber = ( int ) moneynumber