C# Test1

Home > Preview

The flashcards below were created by user slc53 on FreezingBlue Flashcards.


  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. How do you create a form?
    • in class Program{
    • static Form test1_Review;

    • in static void Main(string[] args)
    • {
    • test1_Review = new Form();
    • test1_Review.Size = new Size(400, 300);
    • test1_Review.Text = "Test1 Review Window";

    Application.Run(test1_Review);
  16. How do you add a label called firstLabel?
    • in class Program{
    • static Form formName;
    • static Label firstLabel;

    • in static void Main{
    • firstLabel = new Label();
    • firstLabel.Size = new Size(50, 20);
    • firstLabel.Text = "first Label";
    • firstLabel.Location = new Point(10, 10);

    test1_Review.Controls.Add(firstLabel);

    Application.Run(test1_Review);
  17. How do you add a textbox called firstTxtBox?
    • in class Program{
    • static TextBox firstTxtBox;

    • in static void Main{
    • firstTxtBox = new TextBox();
    • firstTxtBox.Size = new Size(100, 20);
    • firstTxtBox.Text = "stuff";
    • firstTxtBox.Location = new Point(10, 40);

    test1_Review.Controls.Add(firstTxtBox);

    Application.Run(test1_Review);
  18. How do you create a playAgain button?
    • in class Program{
    • static Button playAgainBtn;

    • in static void Main{
    • playAgainBtn = new Button();
    • playAgainBtn.Text = "Play Again";
    • playAgainBtn.Size = new Size(50, 20);
    • playAgainBtn.Location = new Point(10, 70);
    • playAgainBtn.Click += Continue;

    test1_Review.Controls.Add(playAgainBtn);

    Application.Run(test1_Review);

    • private static void Continue(object sender, EventArgs e)
    • {
    •      test1_Review.Close();
    • }

Card Set Information

Author:
slc53
ID:
320140
Filename:
C# Test1
Updated:
2016-05-16 16:18:00
Tags:
Test1
Folders:

Description:
C# Test1
Show Answers:

Home > Flashcards > Print Preview