NotifyCollectionChangedEventArgs checking what it contains
This is my implementation of method I use as a parameter of:
System.Collections.Specialized.NotifyCollectionChangedEventHandler
->
void _students_CollectionChanged(object sender,
System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
string xxx = '';
if (e.NewItems != null && e.NewItems[0] != null && e.NewItems[0] is
Student)
{
xxx = (e.NewItems[0] as Student).Name;
}
lstLog.Items.Add(string.Format("{0} Name:", xxx));
}
As you can see I use triple check to make sure that the program will not
crush here.
Is there any better way of solving this problem?
Thank you!
No comments:
Post a Comment