2017-02-21 2 views
-2
I 클래스가 포함되어 일부 기존 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 

내가 필요로하는 특성 (날짜)를 사용하려고, 난이 얻을를 오류 :

Error CS1061 'tagTLSEEKINFO[]' does not contain a definition for 'Date' and no extension method 'Date' accepting a first argument of type 'tagTLSEEKINFO[]' could be found (are you missing a using directive or an assembly reference?) TrendLogFileViewer

+1

오류가 발생하는 라인을 표시 할 수 있습니까? – Allen

+2

문제가 확실하게 재현되는 좋은 [mcve]가 없다면 확실히 말할 수는 없습니다. 그러나 오류 메시지를 기반으로, 당신은'tagTLSEEKINFO' 객체의 배열을 가지고 있으며 배열을 색인화하고 배열의 단일 요소에서 속성 값을 검색하는 대신 배열에서'Date' 속성 값을 검색하려고합니다 . 너는 그렇게 할 수 없다. 값을 가져 오려는 요소를 알아 내고 해당 요소를 가져 오는 데 적절한 색인 값을 사용하십시오. –

답변

1

오류는 tagTLSEEKINFO 객체의 배열에 재산 Date를 사용하려고 시도하고 있음을 나타냅니다. foreach 루프를 사용하여 개별적으로 액세스 해보십시오.

foreach(var seekInfo in <yourtagTLSEEKINFOArrayVariable>) 
{ 
    seekInfo.Date; //you can access `Date` here 
} 
+0

감사! 그거였다; 나는 주로 파이썬으로 프로그래밍을 해왔고 방금 그것을 놓쳤다. –