Wednesday, 6 May 2015

Collection was modified; enumeration operation may not execute.

This error was happened in my Asp.net c# project ,specifically in a for loop iterating through the contents in a list . 

My code something like this :

 foreach (RequestContent content in  Contents)
{
    do something 
}

I googled for this type of error and finally got a solution .

I changed the code to :
 foreach (RequestContent content in  Contents.ToList())
{
    do something 
}
 and it worked fine.

The issue was that Contents was getting modified inside the loop. Calling Contents.ToList() copies the values of Contents to a seperate list at the start of the loop .No one can access this list . so nothing can modify it inside the loop and it worked perfectly .




Monday, 8 April 2013

Fancy some good ideas for Life?

Fancy some good ideas for Life?

Remembering one old saying below:

“There is nothing so powerful as an idea whose time has come.”- Victor Hugo.

Does it speaks thousand words?
















I found keeping the following tips   in mind will keep me strong enough :

You Are Free to Choose
Think for Yourself and Question Authority
You Could Die Tomorrow
One Person Can Make a Difference
Life Is A Miracle
The Poor Work for Money, The Rich Have Money Work For Them
The Power of Belief