我很难找到一段将成功读取文件并将信息存储在单独数组中的代码。
有人建议
var lines = File.ReadAllLines("peter_testresults.txt");
在过去的问题中,但“var”未被识别。
代码:
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
{
}
}
}