extension methods - Casting and Linq Cast<T>() -


While trying to answer, I searched the following:

  string s = "Test"; Var result 1 = s.Select (c => (ushort) c); // work fine var result2 = s.Cast & lt; Ushort & gt; (); // An unlawful artist throws an exception  

Why Cast & lt; T & gt; () here fails? What is the difference?

Think you will find your answer here:

IEnumerable & LT; T & gt; . This means that every time from time to time every value is delivered to the point where it is being inserted, it already has System.Object


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -