参考

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

namespace ConsoleApp1
{
    class Program
    {
       // private delegate void BuyBook();
        static void Main(string[] args)
        {

            //BuyBook buybook = new BuyBook(Book);
            //buybook();
            //Action<string> BookAction = new Action<string>(Book);
            //BookAction("百年孤独");
            //Func<string> RetBook = new Func<string>(FuncBook);
            //Console.WriteLine(RetBook());
            //Func<string, string> RetBook = new Func<string, string>(FuncBook);
            //Console.WriteLine(RetBook("aaa"));
            Func<string> funcValue = delegate
            {
                return "我是即将传递的值3";
            };
            Func<List<Student>> funcValue2 = delegate
            {
                List<Student> list = new List<Student>()
            {
                new Student(){SName="张同学",SAge=11,Ssex="男"},
                 new Student(){SName="李同学",SAge=12,Ssex="男"},
                 new Student(){SName="王同学",SAge=13,Ssex="男"},
                 new Student(){SName="赵同学",SAge=14,Ssex="男"},
            };
                return list;
            };
            DisPlayValue(funcValue);
            DisPlayValue2(funcValue2);
            Console.ReadKey();
        }
        private static void DisPlayValue(Func<string> func)
        {
            string RetFunc = func();
            Console.WriteLine("我在测试一下传过来值:{0}", RetFunc);
        }
        private static void DisPlayValue2(Func<List<Student>> func)
        {
            List<Student> list = new List<Student>();
            list = func();
          
        }
        public static void Book(string BookName)
        {
            Console.WriteLine("我是买书的是:{0}", BookName);
        }
        public static string FuncBook()
        {
            return "送书来了";
        }
        public static string FuncBook(string BookName)
        {
            return BookName;
        }
    }
    public class Student
    {

        public string SName { get; set; }

        public int SAge { get; set; }

        public string Ssex { get; set; }
    }
}

 

posted on 2019-01-03 10:57  红磨坊后的白桦树  阅读(151)  评论(0编辑  收藏  举报