过去的几个小时中,我一直在尝试纠正这些错误。我不确定为什么我会收到_field的这些声明错误。我尝试在顶部和范围内进行声明,但错误未更改。我也很疲倦地宣布_field为私有。如果您可以举一个示例代码段的示例,那将会很有帮助。我加粗了错误消息发生的位置。
**代码:
public class FileClass
{
#region ' Declarations '
private string TEMP_FILE = "~tmpData.txt";
private GenericParserAdapter _parser;
private int _fieldID;
private int _profileID;
private string _name = string.Empty;
private string _dataType = string.Empty;
private int _length = 0;
private Boolean _isKey = false;
private Boolean _inCompare = false;
private int _startPosition = 0;
private int _endPosition = 0;
public int _field;
public enum FileType
{
CharacterRanges,
Delimited
}
private string _location = string.Empty;
private FileType _type;
private DataTable _data;
private Boolean _firstRowContainsFieldNames = true;
public class ProfileClass
{
public ProfileClass _profile = new ProfileClass();
}
public class FieldCollectionClass
{
private FieldCollectionClass _ComparisonFileOne = new FieldCollectionClass();
private FieldCollectionClass _ComparisonFileTwo = new FieldCollectionClass();
}
#endregion
private void CreateDefaultFieldNames(DataTable ParsedTable)
{
// ADD LINE COLUMN HEADER
ParsedTable.Columns[0].ColumnName = "Line";
// NAME COLUMN HEADERS
for (int i = 0; i < this._profile._field.Count; i++)
{
FieldCollectionClass field = this._profile._field[i];
ParsedTable.Columns[i + 1].ColumnName = field._name;
this._fields.Add(field);
}
}
private void BuildParser(Boolean IsFixedLengthFile)
{
_parser.FirstRowHasHeader = this._firstRowContainsFieldNames;
if (IsFixedLengthFile)
{
_parser.FixedWidth = true;
int[] columnWidths = new int[this._profile._field.Count];
int index = 0;
// BUILD COLUMN WIDTHS
foreach (FieldClass field in this._profile._field)
{
columnWidths[index] = _field.Length;
index++;
}
_parser.ColumnWidths = columnWidths;
}
else
{
_parser.SetColumnDelimiter(',');
}
}
#endregion
错误:
“ FileName”不包含“ _field”的定义,也没有扩展方法“ _field”接受类型的第一个参数。
答案 0 :(得分:0)
您知道此代码吗?
public class ProfileClass
{
public ProfileClass _profile = new ProfileClass();
}
您认为它将产生多少个实例?