2012-12-03 75 views
0
//Class A 
void OnChanged(object source, FileSystemEventArgs e) 
{ 
XmlTextReader reader = new XmlTextReader("?"); <- How will I pass the "file" variable from Class B? 
} 

//Class B 
public static bool myMethod(FileInfo file) 
{ 
//some codes here 
return false; 
} 

我知道你必須爲此傳遞一些屬性來傳遞變量,但我不確定從哪裏開始。添加一些代碼可以幫助我更好地理解屬性。將A類方法中的參數傳遞給B類

回答

1
//Class B 
public static FileInfo myFileProperty 
{ 
    get; 
    set; 
} 

public static bool myMethod(FileInfo file) 
{ 
//some codes here 
myFileProperty = file; 
return false; 
} 


//Class A 
void OnChanged(object source, FileSystemEventArgs e) 
{ 

XmlTextReader reader = new XmlTextReader(ClassB.myFileProperty); 
} 
+0

謝謝!這正是我正在尋找的.. – Blackator

相關問題