Possible Duplicate:
C# “as” cast vs classic cast
What is the difference between these two expressions?
(ListView)sendersender as ListView
In General, I usually used the exp sender as ListView.
But in SO i find that most times users use (ListView)sender.
So, I want to know which one is more efficient.
Or,
If it is the choice of the coder, which one to use[and both works the same way]??
The difference is that
(ListView)sender will throw an exception if sender isn’t a ListView, but sender as ListView will not throw an exception and return null instead if the cast is invalid.