A Sample example to Seperate strings from collection of integers,strings

Prabhukiran345
Posted by Prabhukiran345 under LINQ category on | Points: 40 | Views : 1334
This can be achieved by using OfType

Ex:
static void Main(string[] args)
{
ArrayList al = new ArrayList { "Hello", 200, "kiran", false, 100 };
var onlyStr = al.OfType<string>();
Console.WriteLine("Printing Only Strings");
foreach(var str in onlyStr)
Console.WriteLine(str);
Console.ReadLine();
}

Comments or Responses

Login to post response