In this programming problem assignment from CHAPTER 7, PROGRAMMING PROBLEM NUMBE
ID: 3774771 • Letter: I
Question
In this programming problem assignment from CHAPTER 7, PROGRAMMING PROBLEM NUMBER 5 from the STARTING OUT WITH VISUAL C# textbook, I'm to create an application that displays the contents of the Teams.txt file in a ListBox control; then when a user selects a team in this ListBox, the application should display the number of times that team has won the World Series (from the teams listed in the WorldSeriesWinners.txt file. It is advised in the textbook to read the contents of WorldSeriesWinners.txt into a List or an array.
Explanation / Answer
Actually i am not completely getting you as you mentioned a particular book name and a particular question number better you will provide a screenshot of your problem or just type the whole content without mentioned the book name or problem number as these are paid content and only access by you as you are paying for that
But as far as you want to read the contents of WorldSeriesWinners.txt into a List or an array-
You want to use predefined method in c# known as Split method in this which is used to read data from a string or from a text file and save the content in array or arraylist
you can use the following syntax-
static void Main(string[] args)
{
var lines = File.ReadAllLines("WorldSeriesWinners.txt");
for (int i = 0; i < lines.Length; i++)
{
var fields = lines[i].Split(' ');
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.