【C# Lab】0001 委託(delegate)

示例:創建一個委託,在用戶請求輸入時,使用它模擬Console.ReadLine()函數

using System;
using static System.Console;

namespace test
{
    class Program
    {
        delegate string ReadLineDelegate();
        static void Main(string[] args)
        {
            ReadLineDelegate readline = new ReadLineDelegate(ReadLine);
            WriteLine("readline");
            string input = readline();
            WriteLine("input={0}",input);
            ReadKey();
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章