整理代码
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user