✅ Using Linq's Cast Method
I've never been able to get it to not warn and throw errors except for one, maybe two times. It is always warning me even if the cast is what I want and has thrown over it before. These casts are trivial casts like casting an int to another value type like long or char. I also have never really bothered asking about it since I just do
Say I had an IEnumerable of random ints. Why can't I just do
.Select(o => (T)o) in the end.Say I had an IEnumerable of random ints. Why can't I just do
.Cast<char>() if I wanted to cast them into chars instead of doing .Select(i => (char)i)? If I can, what am I missing to do so?