Can anyone explain to me what the following line of C# code does?
public event EventHandler<DataEventArgs<BusinessEntities.Employee>> EmployeeSelected = delegate { };
The bit that's really got me stumped is the delegate { }
piece at the end. For a bit more context, the sample from the EmployeesListView.xaml.cs in the ViewInjection sample that ships with PRISM 2. The full class definition is shown below:
/// <summary>
/// Interaction logic for EmployeesListView.xaml
/// </summary>
public partial class EmployeesListView : UserControl, IEmployeesListView
{
public EmployeesListView()
{
InitializeComponent();
}
public ObservableCollection<BusinessEntities.Employee> Model
{
get { return this.DataContext as ObservableCollection<BusinessEntities.Employee>; }
set { this.DataContext = value; }
}
public event EventHandler<DataEventArgs<BusinessEntities.Employee>> EmployeeSelected = delegate { };
private void EmployeesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
BusinessEntities.Employee selected = e.AddedItems[0] as BusinessEntities.Employee;
if (selected != null)
{
EmployeeSelected(this, new DataEventArgs<BusinessEntities.Employee>(selected));
}
}
}
}