C# 第117行错误,异常未处理

C# 第117行错误,异常未处理,c#,visual-studio-2015,C#,Visual Studio 2015,我做错了什么?我试图让我的程序从csv文件中读取数据,但我一直得到这个未处理的异常,这是因为我是如何编写txt文件的吗?例外 首先,我尝试在控制台中将数据显示为列表,但也没有实现。我似乎无法在这里做到这一点,甚至无法正确读取我的txt文件 //My first program using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.T

我做错了什么?我试图让我的程序从csv文件中读取数据,但我一直得到这个未处理的异常,这是因为我是如何编写txt文件的吗?例外

首先,我尝试在控制台中将数据显示为列表,但也没有实现。我似乎无法在这里做到这一点,甚至无法正确读取我的txt文件

//My first program 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PracticeProgram
{
public class Program
{
    public static bool W2 { get; private set; }

    public static void Main(string[] args)
    {            
        List<Person> myContacts = new List<Person>();

        // Loop to collect developers data
        for (int i = 0; i < 4; i++)

         {
            Console.WriteLine("Welcome developer, enter your name to continue");
            string name = Console.ReadLine();
            Console.WriteLine("Hello, " + name);

            Console.WriteLine("enter your address");
            string address = Console.ReadLine();
            Console.WriteLine(address);

            Console.WriteLine("enter your monthly income");
            double GrossMonthlyPay = 5000;
            Console.WriteLine(GrossMonthlyPay);
            Console.ReadLine();

            Console.WriteLine("your tax deduction is set at 7%");
            double taxes = (0.07);
            Console.WriteLine(taxes);
            Console.ReadLine();

            Console.WriteLine("your monthly tax deduction is ");
            Console.WriteLine(taxes = GrossMonthlyPay * taxes);
            Console.ReadLine();

            Console.WriteLine("Based on your monthly income your Annual gross pay is ");
            double AnnualGrossPay = GrossMonthlyPay * 12;
            Console.WriteLine(AnnualGrossPay);
            Console.ReadLine();

            Console.WriteLine("Your annual taxes are ");
            double AnnualTaxes = AnnualGrossPay * 0.07;
            Console.WriteLine(AnnualTaxes);
            Console.ReadLine();

            Console.WriteLine("Select 1 for W2, select 2 for 1099");
            bool A = W2;
            Console.WriteLine();
            Console.ReadLine();

            if (A)
            {
                Console.WriteLine("You employment type is W2");
            }
             else
            {
                Console.WriteLine("Your employment type is 1099");
            }                           

            Console.Write("\nPress any key to continue...");
            Console.ReadLine();

            myContacts.Add(new Person(name, address, GrossMonthlyPay, taxes, AnnualGrossPay, AnnualTaxes));
        }
        // Or you could read from CSV or any other source
        foreach (string line in System.IO.File.ReadLines(@"C:\Users\Owner\Documents\Visual Studio 2015\Projects\new\data.txt"))
        {
            myContacts.Add(Person.ReadFromCSV(line));
        }

        // Serialize your informations at the end
        foreach (Person contact in myContacts)
        {
            contact.SerializeToCSV(@"C:\Users\Owner\Documents\Visual Studio 2015\Projects\new\data.txt");
        }
    }
}

internal class Person
{
    private string address;
    private double grossMonthlyPay;
    private string name;
    private double taxes;
    private double annualGrossPay;
    private double annualTaxes;

    public Person(string name, string address, double grossMonthlyPay, double taxes)
    {
        this.name = name;
        this.address = address;
        this.grossMonthlyPay = grossMonthlyPay;
        this.taxes = taxes;
    }

    public Person(string name, string address, double grossMonthlyPay, double taxes, double annualGrossPay, double annualTaxes) : this(name, address, grossMonthlyPay, taxes)
    {
        this.annualGrossPay = annualGrossPay;
        this.annualTaxes = annualTaxes;
    }

    public override string ToString()
    {
        return "Name=" + this.name + ",Address =" + this.address + " Monthly Pay=" + this.grossMonthlyPay + " Taxes=" + this.taxes.ToString();
    }

    internal static Person ReadFromCSV(string line)
    {
        throw new NotImplementedException();
    }

    internal void SerializeToCSV(string v)
    {
        throw new NotImplementedException();
    }
}
}


您的函数ReadFromCSV实现了一个

throw new NotImplementedException();

尝试删除它或使用正确的代码执行

哪一行显示错误?错误消息是什么,saysline 117@un-lucky,它告诉我方法或操作没有实现,不确定这意味着什么,因为我已经知道了did@un-幸运的是,我添加了一个屏幕截图供参考。没必要生气,我只是想学习。你自己的代码抛出了异常。使用调试器,在最后一个foreach上设置断点并单步执行。顺便说一句,写入CSV与序列化不同。另外,下次在标题上花更多的时间来描述实际问题,少花时间告诉我们您对java vs的看法c@Plutonix我不是在尝试写CSV,而是在尝试从中读取,这是我在代码中编写的内容。该死,这比我想象的要难。