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

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -