Linq OfType Extension Operator

Akiii
Posted by Akiii under LINQ category on | Points: 40 | Views : 1593
Suppose you have an array of type object,

Object[] arrobj = { 2.0, null, "one", 4, "ten", 6, "one", 10.0 }; 

var doubles = arrobj.OfType<double>();

Console.WriteLine("Numbers stored as doubles:");
foreach (var temp in doubles)
{
Console.WriteLine(temp);
}


Numbers stored as doubles:
2.0
10.0



Thanks and Regards
Akiii

Comments or Responses

Login to post response