2012-12-03 4 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

관련 문제