Blackator
Blackator

Reputation: 1561

Passing a parameter from class A method to class B

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

I know you have to put some properties for this to pass the variable but I'm not sure yet where to start. Adding some codes may help me understand properties better.

Upvotes: 0

Views: 68

Answers (1)

Arsalan Adam Khatri
Arsalan Adam Khatri

Reputation: 556

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

Upvotes: 1

Related Questions