Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8684515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:19:43+00:00 2026-06-12T22:19:43+00:00

I am having difficulting locating a piece of code that will successfully read a

  • 0

I am having difficulting locating a piece of code that will successfully read a file and store the information in a separate array.

Someone has suggested

var lines = File.ReadAllLines("peter_testresults.txt"); 

in a past question but “var” is not recognized.

CODE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;

    namespace WindowsFormsApplication4
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            //return a pass/fail
            //return number of correct answers
            //return number of incorrect answers
            //return index figures of incorrect values

    correctAnswers ={B,D,A,A,C,A,B,A,C,D,B,C,D,A,D,C,C,B,D,A} 


    private string determinePassOrFail (); //return a pass/fail


        string[] lines= File.ReadAllLines("peter_testresults.txt");

        var c = correctAnswers.Where((x, i) => x.Equals(lines[i])).Count();





     private int numberCorrectAnswers(); //return number of correct answers
        {

        }


    private int numberIncorrectAnswers(); //return number of incorrect answers

    {

    }

    private string questionsIncorrectAnswers(); //return index figures of incorrect
  values

    {

    }





    }
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:19:45+00:00Added an answer on June 12, 2026 at 10:19 pm

    If you can’t use var (implicitly typed local variables) then that suggests you’re using a C# 2 compiler (e.g. VS2005), and therefore almost certainly .NET 2. (I’m assuming you’re not stuck with C# 1…)

    Alternatively, you could be trying to use this as a field:

    class Foo
    {
        var lines = File.ReadAllLines("...");
    }
    

    That won’t work as fields can’t be implicitly typed – but I’d argue that doing that IO in a field initializer is a bad idea anyway…

    This should still work though:

    string[] lines = File.ReadAllLines("peter_testresults.txt");
    

    as File.ReadAllLines was first introduced in .NET 2.

    As an aside, I’d strongly advise you to try to upgrade to a more modern version of C#…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having difficulties with my state machine. I use a function that returns
I'm having difficulties understanding why the below code doesn't work, what I want to
I'm having difficulties drawing an image in an NSRect, the code below creates an
I am having difficulties to code a simple jquery enlarge image feature on a
I'm having difficulties working with some legacy enums that have multiple zero values. Whenever
I am having difficulties in implementing a simple TCP server. The following code is
I'm having difficulties returning a user input string. If I have a code: System.out.println(please
I'm having difficulties testing python functions that return an iterable, like functions that are
I am having difficulties importing a script from a directory that is not stored
I'm having difficulties understanding why the following line of code works in node.js: server.listen(12345,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.