//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;
}
我知道你必须为此传递一些属性来传递变量,但我不确定从哪里开始。添加一些代码可以帮助我更好地理解属性。
答案 0 :(得分: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);
}