0

What is the difference between the two lines of code below? Functionally, I believe them to be identical, but is there a certain case or best practice that would dictate which one I should use?

TreeViewItem selectedItem = MyTreeView.SelectedItem as TreeViewItem;

TreeViewItem selectedItem = (TreeViewItem)MyTreeView.SelectedItem;
Foxtrek_64
  • 357
  • 5
  • 14
  • 1
    They're not functionally equivalent; see linked question – Rob Jun 29 '17 at 00:34
  • Thanks for the help. This is a good example of knowing how to ask the question it seems - I was looking for explicit casts, not for the `as` keyword. – Foxtrek_64 Jun 29 '17 at 00:38

0 Answers0