Code Review Flashcards
What property is being used to change the background color for every element?
- BackColor
What property is being used to set the element’s variable name?
- Name ( in Design )
List out 5 values for image size mode
- Zoom
- StretchImage
- Normal
- AutoSize
- CenterImage
List out 2 values for the Visible property
- True
- False
How to change the element text shown at the UI?
- Change the text at the Text property
List out 9 properties for Text Alignment
- Top Left
- Top Center
- Top Right
- Middle Left
- Middle Center
- Middle Right
- Bottom Left
- Bottom Center
- Bottom Right
What property is set to ensure that the elements doesn’t relocate when the windows expand or shrink?
- Anchor
What property is being used to change the text color?
- ForeColor
What property in TextBox is used to hide the letters input?
- PasswordChar
- Example
When set to *
Input 1234 will turn **
List out 5 types of events
- Activate Events
- Selects item on screen
- Changed Events
- Modified control property
- Focus Events
- Control gets or loses focus
- Key Events
- Interact with keyboard
- Mouse Events
- Interact with mouse
How to show the dialog box the shows the message when a button is pressed?
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(“Hello”);
}
What property allows changing the element’s text font, font style, and font size?
- Font
List out 3 values that can be set in the BorderStyle
- None
- FixedSingle
- Fixed3D
Which properties can be used to enable auto size method?
- AutoSize
What is an assignment operator?
- =
How to assign the text from label1 to another text Hello?
- label1.Text = “Hello”
How to change the label1 background color to another color ( blue ) after a button is pressed?
private void button1_Click(object sender, EventArgs e)
{
label1.BackColor = Color.Blue ;
}
this.BackColor = Color.Red;
// Will change the background color for the current form
this inside a class means the current instance of the class
How to use concatenation?
- Use the + operator on string value to combine 2 string
“Welcome” + “to C#”
1 + 1 = 2
“1” + “1” = 11
List out how to write comment on
1. Single Line Comment
2. Multiline Comment
- //
- /**/
What is identation being used for?
- Make code more human readable
How to close the current application form when a button is clicked?
private void exitButton_Click(object sender, EventArgs e)
{
// Close the form.
this.Close();
}
List out 3 types of error
- Syntax Errors
- Show with jagged line
- MessageBox.Sh(“Hi)
- Run-time Errors
- Errors when program runs
- num = 100 / 0
- Logic ( Semantic ) Errors
- age = 2024 + bornYear
How to declare variable car to store string Perodua?
- string car = “Perodua”
How to declare variable age with current year ( DateTime ) minus birth year ( txtBornYear ) ?
int birthYear = int.Parse(txtBornYear.Text);
static int currentYear = DateTime.Now.Year;
int age = currentYear - birthYear ;
Improvement with Error Checking
int birthYear;
if (int.TryParse(txtBornYear.Text, out birthYear))
{
int currentYear = DateTime.Now.Year;
int age = currentYear - birthYear;
MessageBox.Show(“You are “ + age + “ years old.”);
}
else
{
MessageBox.Show(“Please enter a valid year.”);
}