c# List.ForEach

프로그래밍 2012. 2. 23. 09:41
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        List<String> names = new List<String>();
        names.Add("Bruce");
        names.Add("Alfred");
        names.Add("Tim");
        names.Add("Richard");

        // Display the contents of the list using the Print method.
        names.ForEach(Print);

        // The following demonstrates the anonymous method feature of C#
        // to display the contents of the list to the console.
        names.ForEach(delegate(String name)
        {
            Console.WriteLine(name);
        });
    }

    private static void Print(string s)
    {
        Console.WriteLine(s);
    }
}

툴개발하다가 자꾸 까먹어서 적어놔염

List 에 담긴 객체들 delegate 된 함수로 한방에 일괄작업!! msdn 펌~ 
Posted by 알 수 없는 사용자
,