Read a file and get specific contents in an array


I'm very new to C# and I need your help. I have a file named myData.txt with the following data in it.

Johnson 85 83 77 91 100 Aniston 80 90 95 93 48 Chen 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Lamah 100 100 100 100 100

The first three scores are 'Assignments' and the last two scores are 'Exams'. All the names should go into a 1-dimensional array Assignments into a 2-dim array also Exams into a 2-dim array

My ultimate aim is to find out the average of assignments & exams for each student.


This is a homework assignment, so I'll just give you hints:

<ol><li>You can use StreamReader to open the file: <a href="http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx" rel="nofollow">StreamReader</a></li> <li>Looks like each line ends with a new line. You can loop through the file and read each line via StreamReader's ReadLine method: <a href="http://msdn.microsoft.com/en-us/library/system.io.streamreader.readline.aspx" rel="nofollow">ReadLine</a></li> <li>It looks like each line is delimited by tab. You can split the string returned by ReadLine on tab by using String's split method: <a href="http://msdn.microsoft.com/en-us/library/system.string.split.aspx" rel="nofollow">Split</a>. The char code for tab is '\t'. Splitting the string will put it into an array.</li> <li>Convert the scores to a number, add, and then divide at the end to get the mean.</li> </ol>


  • Create a field in form for each model instance related to another instance in django
  • access sql average three columns
  • AVERAGE multiple rows in a column in Access
  • object HTMLSelectElement accessing value through this keyword
  • WPToolkit not appear in the references after successful install
  • How do I save GORM objects with multiple many-to-one relationships?
  • Change language to Bootstrap Datetimepicker
  • Get List of Specific 2 Limits of Records from Single Table in Single Query
  • How to make gcc or ld report undefined symbols but not fail?
  • DataAnnotations tryvalidateobject always returns true
  • Using numpy.unique on multiple columns of a pandas.DataFrame
  • Hibernate TransientPropertyValueException When saving data
  • Working with EditorTemplates and radio buttons
  • How to access the Internet through Proxy in C#
  • map return undefined array of object?
  • MATLAB can't seem to find csaps() in MATLAB 7.10.0 student edition
  • What is 1NF truly?
  • How to read csv file into an Array of arrays in scala
  • Doctrine DQL returning flat array from join
  • Is it safe to uninstall VS Express after installing VS Ultimate?
  • Fold function in Octave
  • Linked tables and Slicer in excel
  • Titanium doesn't recognize Android SDK on Windows
  • Double-click autofill - dynamic based on adjacent cell
  • Excel VBA URLDownloadToFile Error for https Ressource
  • Creating a Multidimensional, Associative Array in VBScript
  • JQuery .html() remove line break on IE 8
  • Conversion from string “a” to type 'Boolean' is not valid
  • Installed module is empty
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • Linker errors when using intrinsic function via function pointer
  • Benchmarking RAM performance - UWP and C#
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Unable to use reactive element in my shiny app