TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Akkiraju Ivaturi
NA
8.7k
4.2m
Print, print, print...
Sep 7 2012 11:22 PM
Here's some code using the anonymous method feature of C# 2. What does it do?
using
System;
using
System.Collections.Generic;
class
Test
{
delegate
void
Printer();
static
void
Main()
{
List<Printer> printers =
new
List<Printer>();
for
(
int
i=0; i < 10; i++)
{
printers.Add(
delegate
{ Console.WriteLine(i); });
}
foreach
(Printer printer
in
printers)
{
printer();
}
}
}
Reply
Answers (
1
)
Silly arithmetic
Literally nothing wrong with the compiler here...