1. Message Box Syntax - CORRECT ANSWER MessageBox.Show("[Message]");
2. ListBox control - CORRECT ANSWER Used to create a ListBox control class
object. Properties include Name, Items, Sorted, SelectedItem, and SelectedIndex.
Methods include Items.Add(), Items.Remove(), and Items.Clear(). Events include
SelectedIndexChanged.
3. for loop - CORRECT ANSWER Loops that have a predetermined beginning,
end, and increment (step interval). In the for (i = 0; i <20; i++) { ... }
4. do-while loop - CORRECT ANSWER do { ... } while (condn) Note: Runs through
statements at least once before it reaches the while condition
5. while loop - CORRECT ANSWER while (condn) { ... } Note: Can run for [0, ∞)
repetitions
6. Nested Loop - CORRECT ANSWER A loop inside the body of another loop.
Your inner loop does a task, which actually is iterative in nature and your outer
loop does that task again and again depending on your condition.
7. File I/O - CORRECT ANSWER stands for file input/file output.
8. StreamReader - CORRECT ANSWER An object used to open a text file and read
streams of text, uses the ReadLine command
9. StreamWriter - CORRECT ANSWER An object used to open a text file and write
to it, uses the WriteLine command, if true(adds new line) if false(overwrites)
10. What happens if I don't close a file after I open it to use StreamWriter? -
CORRECT ANSWER All of the data in the original file will be erased so make
sure you make a copy of the file before using StreamWriter just in case.
11. Methods - CORRECT ANSWER Creating new custom commands to make
programs cleaner/less repetitive
12. Using methods - CORRECT ANSWER To call a method, simply write the
following: [name of object].(method with or without parameters as inputs)
13. In methods, what is the difference between void and returning? - CORRECT
ANSWER The void keyword is used in method signatures to declare a method
that does not return a value. A method declared with the void return type cannot
provide any arguments to any return statements they contain. Methods with
, EGR 1400 FINAL EXAM WITH COMPLETE SOLUTIONS
return statements take in arguments, manipulate them in some way, and return a
manipulated value of some specified type.
14. Public vs Private keywords in methods - CORRECT ANSWER Public methods
are written in one project and are able to be accessed by other projects. Private
methods limit the method's use to only the project containing it.
15. Passing parameters by reference - CORRECT ANSWER The variable will be
passed in updated and passed back out. Before being referenced by a ref method,
variables remain in their initial condition. Once they are passed through the ref
method, the variable remains changed as it was manipulated in the method.
16. Passing parameters by value - CORRECT ANSWER The variable will be passed
in and not updated. Changes are made to 'copies' of the input variables.
17. Return values - CORRECT ANSWER The specified type of values you want a
method to return once it manipulates the initial parameters.
18. Form-level variable - CORRECT ANSWER Variable that can be used by any
method in a form.
19. Method-level Variables - CORRECT ANSWER Variables whose use is limited to
the method in which they are initialized.
20. Arrays - CORRECT ANSWER Variables that can store groups of the same type
of values without having to create multiple individual variables. (Think of it like
filling up a bookshelf where each slot in memory is a shelf. Also, remember that
the index starts at 0 meaning if you create an array like int[5], the index will go
from 0 to 4.)
21. Structs - CORRECT ANSWER Kinda like creating your own objects to perform
whatever functions you define them to.
22. Arrays of structures - CORRECT ANSWER After creating a struct with multiple
parameters as inputs, you can do structName[ ] structArr = new structName[# of
slots] so that the slots in the array can store multiple values from the parameters
passed into the struct.
23. Passing arrays as parameters into methods - CORRECT ANSWER Arrays are a
reference type in C#. This means that each time an array is passed as an
argument to any function, the reference (or pointer) to the argument is passed to
, EGR 1400 FINAL EXAM WITH COMPLETE SOLUTIONS
the function. Thus any modifications you make to the array in the function are
made in the actual argument also.
24. Reading from files with StreamReader - CORRECT ANSWER When you create
the instance of the StreamReader class, you provide the relative or absolute path
to the file.
Initialized by System.IO.StreamReader readerName;
readerName = System.Io.File.OpenText("Input.txt");
25. Writing to files with StreamWriter - CORRECT ANSWER StreamWriter writes
new data into a file by replacing its original contents with the changed version.
Initialized by System.IO.StreamWriter writerName;
writerName = System.IO.File.CreateText("Input.txt");
26. LINQ - CORRECT ANSWER Stands for Language Integrated Query.
Super useful for populating fields as the form loads (so it doesn't need to be
triggered by an event to appear).
You can populate a string using a text file a lot easier than StreamReader/Writer
by doing:
string[ ] strArr = File.ReadAllLines("Input.txt");
*This works as long as the input file is in the same folder as the project*
You can also populate a numeric array and listbox using a text file by doing:
int [ ] nums = new int[100];
string[ ] strArr = File.ReadAllLines("Numbers.txt");
foreach (string s in strArr)
{
listbox1.Items.Add(s);
}
for (int i = 0; i < 100; i++)
{
nums[i] = int.TryParse(strArr[i]);
}
27. Lab 5 - CORRECT ANSWER Checkboxes: Allows a user to select multiple
options, whereas Radio Buttons allow only one.
Pictures: PicBoxes to put pictures on your form; you can change the Visible
property to decide which image is shown depending on user input.
Slider: Trackbars are used to allow the user to increment values by a set amount
and the limits the number of increments to an inclusively bounded set.
(See Lab 5: Circuit Analyzer example)