6_8_3创建一个委托,在请求用户输入时,使用它模拟Console.ReadLine()函数

来源:互联网 发布:知乎育儿书籍推荐 编辑:程序博客网 时间:2024/05/16 17:56

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

namespace _6_8_3{    class Program    {        //创建 一个delegate        delegate string ProcessDelegate(string str);                static string InputStr(string str)        {            str=Console.ReadLine();            return str;        }

        static void Main(string[] args)        {            string str="0";            ProcessDelegate process;                        //开辟空间,选择函数            process = new ProcessDelegate(InputStr);                        //调用..............传递参数            string var=process(str);                        Console.WriteLine(var                );        }    }}