我正在尝试读入但不输出此csv文件附加的标题行。换句话说,在处理数据行之前先读入标题行,然后忽略它。
命名空间csvtoXML { 班级计划 {
static void Main( string[] args)
{
string[] source = File.ReadAllLines("GBPAY_103188.csv");
XElement GBPAY = new XElement("EmployeeElectionImport",from str in source
let fields = str.Split(',')
select new XElement("ElectionImport",new XElement("EmployeeElection",new XElement("Employee",fields[0]),new XElement("Election","\n",new XElement("EarnDeductType",fields[3]),new XElement("PlanBenefitCode",fields[1],"\n"),new XElement("SingleFamilyCode",fields[2],new XElement("EERate",fields[3],new XElement("ERRate",fields[4],new XElement("AnnualBenefitRate",fields[5],new XElement("EnrollmentCode",fields[6],"\n")
))))) ; ;
Console.WriteLine(GBPAY);
}}}