Linq Example 22 - Of Type

11:06 PM
Linq Query:

//of type
            object[] myCollection = { "",5,"a",3.66,7,"y",2.89,"y",null,6};
            //Now i only want integer values from this collection of object
            
            var myInts = myCollection.OfType();

            foreach (var t in myInts)
            {
                Console.WriteLine(t);
            }


Output:


5
7
6

0 comments:

Post a Comment