In the following example I'm confused about what is occurring with the highlighted statement. Everything works fine but I just don't get what is going on here with the compound assignment.
Thanks for your help.
John
public MainWindow()
{
InitializeComponent();
openFileDialog = new OpenFileDialog();
openFileDialog.FileOk += openFileDialogFileOk;
}
private void openFileClick(object sender, RoutedEventArgs e)
{
openFileDialog.ShowDialog();
}
private void openFileDialogFileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
string fullPathname = openFileDialog.FileName;
FileInfo src = new FileInfo(fullPathname);
fileName.Text = src.FullName;
TextReader reader = src.OpenText();
displayData(reader);
}
private void displayData(TextReader reader)
{
// TODO: add while loop here
}
}
}
I don't understand what is happening in the highlighted line of code.
What is being added toopenFileDialog.FileOk?
openFileDialog.FileOk is the event when user clicks "OK", what I don't understand is
What happens with the statement:openFileDialog.FileOk += openFileDialogFileOk; What is being added to what?
openFileDialogFileOk is a method with a no return value (void). I understand what is happening inside this method, just not the one line of code highlighted.