using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp16
{
    public class Item
    {
        public string name { get; set; }
    }
    
    internal class App
    {

       
        //생성자
        
        public App() 
        {
            ItemFactory factory = new ItemFactory();
            Console.WriteLine();
            
            factory.CreateItem((item) =>
            {
                Console.WriteLine("{0}이 생성되었습니다.", item.name);
            });


        }
       
        
        
       
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp16
{
    internal class ItemFactory
    {
        public ItemFactory() {
            Console.WriteLine("ItemFactory 생성");
        }
        public void CreateItem(Action<Item> action)
        {
            Item item = new Item { name = "아이템" }; 

            action(item);
        }
    }
}

+ Recent posts