我正在调整一些包含类的现有C#代码:
public class tagTLSEEKINFO
{
/* Disable variable visibility on debug. */
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private DateTime date;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string month;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string year;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private int trunk;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private int addr;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private int subzone;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private tagTLFILETYPE filetype;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string path;
public tagTLSEEKINFO()
{
Path = "";
}
public tagTLSEEKINFO(tagTLFILETYPE filetype)
{
FileType = filetype;
}
public tagTLSEEKINFO(tagTLFILETYPE filetype, string _path)
{
Month = "";
Year = "";
Trunk = Addr = Subzone = 0;
FileType = filetype;
Path = _path;
}
public tagTLSEEKINFO(DateTime date, tagTLFILETYPE filetype)
{
Date = date;
Month = date.Month.ToString("00");
Year = date.Year.ToString().Remove(0, 2);
Trunk = Addr = Subzone = 0;
FileType = filetype;
}
public tagTLSEEKINFO(string month, string year, tagTLFILETYPE filetype)
{
Date = new DateTime(Convert.ToInt16(year), Convert.ToInt16(month), 1);
Month = month;
Year = year;
Trunk = Addr = Subzone = 0;
FileType = filetype;
}
public tagTLSEEKINFO(DateTime date, int trunk, int addr, int subzone)
{
Date = date;
Month = date.Month.ToString("00");
Year = date.Year.ToString().Remove(0, 2);
Trunk = trunk;
Addr = addr;
Subzone = subzone;
FileType = tagTLFILETYPE.TRENDLOG;
}
public tagTLSEEKINFO(string month, string year, int trunk, int addr, int subzone)
{
Month = month;
Year = year;
Trunk = trunk;
Addr = addr;
Subzone = subzone;
FileType = tagTLFILETYPE.TRENDLOG;
}
public virtual DateTime Date { get { return date; } set { date = value; } }
public virtual string Month { get { return month; } set { month = value; } }
public string Year { get { return year; } set { year = value; } }
public int Trunk { get { return trunk; } set { trunk = value; } }
public int Addr { get { return addr; } set { addr = value; } }
public int Subzone { get { return subzone; } set { subzone = value; } }
public tagTLFILETYPE FileType { get { return filetype; } set { filetype = value; } }
public string Path { get { return path; } set { path = value; } }
}//end class
当我尝试使用我需要的属性(日期)时,我收到此错误:
错误CS1061'tagTLSEEKINFO []'不包含'Date'的定义,并且没有扩展方法'Date'可以找到接受类型'tagTLSEEKINFO []'的第一个参数(你是否缺少using指令或程序集参考?)TrendLogFileViewer
答案 0 :(得分:1)
该错误表示您尝试在Date
个对象的数组上使用属性tagTLSEEKINFO
。尝试使用foreach
循环单独访问它们:
foreach(var seekInfo in <yourtagTLSEEKINFOArrayVariable>)
{
seekInfo.Date; //you can access `Date` here
}