Question: Write instructions that will do the following. It will open an output file with the directory name options.txt. It will write each of the items

  1. Write instructions that will do the following. It will open an output file with the directory name options.txt. It will write each of the items in a list box named lstOptions onto the output file as a line. When the last item is written, close the file.

Here is what i have, is it correct. If not, how should it be coded using C#?

StreamWriter outputFile;

string theName

outputFile=File.CreateText(options.txt);

while (!outputfile.EndOfStream)

{

theName = outputFile.WriteLine();

lstOptions.Items.Add(theName);

}

namesFile.Close();

2. Write a method which will accept 2 list boxes as parameters and return an integer telling how many times an element of the first list box is found in the of the second list box.

Please answer question 2 using C#, thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!