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;
}

我知道您必须为此设置一些属性才能传递变量,但我不确定从哪里开始。添加一些代码可以帮助我更好地理解属性。

4

1 回答 1

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);
}
于 2012-12-03T06:36:25.980 回答