如何从使用Filehelpers库输出的文本字段中删除可选字段。我使用C#删除写入文本字段的可选字段Filehelpers
例如, 我有一个共享类文件 与属性,如recordnumber,填料,付款,endingspaces
然后,我需要只写recordnumber和支付到文本文件中没有填料。
[FixedLengthRecord(FixedMode.ExactLength)]
public partial class Person
{
[FieldFixedLength(10)]
public string FirstName;
[FieldFixedLength(10)]
public string LastName;
[FieldOptional]
[FieldFixedLength(5)]
public string Optional1;
[FieldOptional]
[FieldFixedLength(5)]
public string Optional2;
[FieldOptional]
[FieldFixedLength(5)]
public string Optional3;
}
class Program
{
private static void Main(string[] args)
{
var engine = new FileHelperEngine<Person>();
Person[] allPersonRecords = GetPersonExportFromDataBase() as Person[];//This will only get the FirstName,LastName,Optional2. No result for Optional1 and Optional3
FileHelperEngine enginePerson = new FileHelperEngine(typeof(Person));
enginePerson.AppendToFile(FileName, allPersonRecords); //Write the records to the file
//Current Output looks like this:John Lee title
//The output which I want is:John Lee title
}
}
请包括您的问题的一些代码。 – Alfergon 2015-03-03 11:24:49
你能详细说明你想输出什么,输出数据的来源等吗? – Ceisc 2015-03-03 11:29:15
@Alfergon您好我已经包含了一些代码 – namelessly12 2015-03-04 04:09:33