C# Test2

  1. What are the min lines need for program?
    • using System;
    • using System.Collections.Generic;
    • using System.Linq;
    • using System.Text;
    • using System.Threading.Tasks;
    • namespace ConsoleApplication1
    • {
    •       class Program
    •       {
    •              static void Main(string[] args)
    •              {
  2. What lines generate random numbers from 1 to 4?
    • Random randGen = new Random();
    • r1 = randGen.Next(4) + 1;
  3. What lines are needed to create forms?
    • using System.Drawing;
    • using System.Windows.Forms;
  4. How do you write to console?
    Console.WriteLine("The random numbers are:{0}, {1}, {2}.", r1, r2, r3);
  5. How to receive input from keyboard?
    input1 = Console.ReadLine();
  6. How do you convert from a string to an int?
    g1 = Convert.ToInt32(input1);
  7. How do you create and add to a list?
    List<Int32> numbers = new List<Int32>(); numbers.Add(r1);
  8. try-catch structure?
    • try
    • {

    • }
    • catch(Exception e)
    • {
    •      cw (e.Message)
    • }
  9. basic input structure
    • valid = false;
    • while (valid == false)
    • {
    •      prompt and input data
    •      try
    •      {
    •            to convert data
    •            if data "in range"
    •                   valid = true
    •      }
    •      catch
    •      {
    •      }
  10. What are keywords?
    abstract as base bool break byte casecatch char checked class const continue decimaldefault delegate do double else enum eventexplicit extern false finally fixed float forforeach goto if implicit in in (generic modifier) intinterface internal is lock long namespace newnull object operator out out (generic modifier) override paramsprivate protected public readonly ref return sbytesealed short sizeof stackalloc static string structswitch this throw true try typeof uintulong unchecked unsafe ushort using virtual voidvolatile whileadd alias ascending descending dynamic from getglobal group into join let orderby partial (type)partial(method) remove select set
  11. How do you know if list contains an item?How do you remove items from a list?
    • numbers.Contains(g1)
    • numbers.Remove(g1);
  12. namespace is a ...
    namespace is a collection of generally related classes
  13. class has:
    • -data/properties
    •      on assignment- related to static
    • -methods / function
    •      on assignment we had a main and 2 event handleing functions
  14. What must be added to references in VS?
    • System.Drawing
    • System.Windows.Form
  15. form load header
    private void Form1_Load(object sender, EventArgs e)
  16. How do you create the string list called shortList?
    List shortList = new List()
  17. How do you add word to shortList?
    shortList.Add("word");
  18. How do you clear shortList?
    shortList.Clear();
  19. How do you remove word from shortList?
    shortList.Remove("word");
  20. How do you know if shortList contains r?
    shortList.Contains(r)
  21. How do you create an array?
    string[] countryPathsArray
  22. How do you determine the number of elements in an array?
    numCountries = countryPathsArray.Count();
  23. How do you split a string?
    • string[] tempArray = countryPath.Split('\\');
    • tempArray is an array of strings.
  24. How do you access the rth index of a string or array?
    answerCountryPath = countryPathsArray[r];
  25. How do you add text to a radio button?
    rb1.Text = shortNameList[0];
  26. How to you add text to a textBox?
    tbAnswer.Text = answerCountryName;
  27. How do you add an image to a picture box?
    pictureBox1.Image = Image.FromFile(answerPath);
  28. How do you add a message box?
    MessageBox.Show("Correct");
  29. How do you know if a radioButton is checked?
    rb1.Checked==true
  30. How do you set a radiobutton to unchecked?
    rb1.Checked = false;
  31. What is the code for radiobutton Mouse Enter?
    • private void rb_MouseEnter(object sender, EventArgs e)
    • {
    • RadioButton rb = (RadioButton)sender;
    • rb.BackColor = Color.Aqua;
    • }
  32. What is the code for radiobutton Mouse Leave?
    • private void rb1_MouseLeave(object sender, EventArgs e)
    • {
    • RadioButton rb = (RadioButton)sender;
    • rb.BackColor = Color.Empty;
    • }
  33. What is the foreach structure?
    foreach (string continentPath in ContinentPathList)
  34. radio button code?
    • private void rb1_CheckedChanged(object sender, EventArgs e)
    • {
    • RadioButton rb = (RadioButton)sender;
    • if (rb.Checked == true)
    • {
    • if (rb.Text == answerName)
    • {
    • score++;
    • MessageBox.Show("Correct");
    • }
    • rb.Checked = false;
  35. The value of a comboBox is a...?
    string
  36. value of a group of radio buttons...
    checked property: 1 true and remainder false
  37. Basic Properties of Controls
    Size, Location, BackColor, ForeColor, Text, Name, Font, checked, enabled, ReadOnly, AutoSize, Visible
  38. Event types:
    Mouse Hover, Mouse Enter, Mouse Leave, Click, checked_Changed, Load, textChanged
  39. Event Handler header
    public void rb1_CheckedChanged(object sender, EventArgs e)
  40. What does the right side of the follow do: RadioButton rb = (RadioButton)sender;
    casts sender to a Radiobutton
  41. How do you declare list of strings called words?
    List words;
  42. A list of strings called words has been declared. How do you instantiate words?
    word = new List
  43. What List methods?
    Add, Remove, Contains, Clear, Concat
  44. What is a list property?
    Count
  45. string[] words; words =new string[10]; string sentence = "Hello World"; words = sentence.Split(' '); What is the size words?
    2("Hello" and "World")
  46. What are basic controls?
    textBox, combobos, radiobuttons, button
  47. How to share an event handler among multiple controls?
    Properties->Events->CheckedChanged-select from list
Author
slc53
ID
320464
Card Set
C# Test2
Description
C# Test2
Updated