整理代码

This commit is contained in:
2024-01-16 18:00:23 +08:00
parent 78cd833617
commit a74cf5ddb7
7 changed files with 344 additions and 136 deletions

View File

@@ -62,4 +62,17 @@ public class DataRecord
public int Count => Fields.Length;
public bool TryGetField(string columnName, out string value) => TryGetField(this, columnName, out value);
public bool SetField(string columnName, string value) => SetField(this, columnName,value);
public bool SetField( DataRecord record,string columnName,string value)
{
if (record.Headers is null)
throw new InvalidOperationException("Headers have not been set.");
var idx = Array.IndexOf(record.Headers, columnName);
if (idx is -1)
throw new IndexOutOfRangeException("Column name not found in this record.");
record.Fields[idx] = value;
return true;
}
}