Just to understand the collection ,I tried to find the square of each number passed in to a collection.
My Code is (Ofcourse I could have implemented in differ way,Just to know casting itretaions,I have made a dummy implementation).
static void Main()
{
ICollection<int> Present = (ICollection<int>)
a.GetNumbers(new int[]{1,2,3});
foreach (int i in Present)
{
Console.WriteLine("{0}", i);
}
}
public IEnumerable<int> GetNumbers(int[] Numbers)
{
//first trial
ICollection<int> col =
Array.ForEach(Numbers, delegate { x => x * x; });
//second trial
ICollection<int> col = Array.ForEach(Numbers, ( x => x * x ));
return (IEnumerable<int>)col.GetEnumerator();
}
What is the problem with Array.ForEach in bothh trails inside GetNumbers() ?
I am receiving "Assignment and call increment is allowed". error.