• .NET Framework : 4.7.2
  •        IDE : Visual Studio Community 2019
  •         OS : Windows 10 x64
  •     typesetting : Markdown

code

using System;

namespace ConsoleApp
{

    // 委托
    // 返回类型 string
    // 参数类型 int
    public delegate string MyDelegate(int num);

    class Program
    {
        static void Main(string[] args)
        {
            MyDelegate test = x => "hello world" + x.ToString();
            string res = test(1);
            Console.WriteLine(res);

            Console.ReadKey();
        }
    }
}

result

hello world1

resource

  • [文档] docs.microsoft.com/zh-cn/dotnet/csharp
  • [规范] github.com/dotnet/docs/tree/master/docs/standard/design-guidelines
  • [源码] referencesource.microsoft.com
  • [ IDE ] visualstudio.microsoft.com/zh-hans
  • [.NET Core] dotnet.github.io


感恩曾经帮助过 心少朴 的人。
C#优秀,值得学习。.NET Core具有跨平台的能力,值得关注。
Console,WinForm,WPF,ASP.NET,Azure WebJob,WCF,Unity3d,UWP可以适当地了解。
注:此文是自学笔记所生,质量中下等,故要三思而后行。新手到此,不可照搬,应先研究其理象数,待能变通之时,自然跳出深坑。

欢迎关注微信公众号:悟为生心

C#基础 delegate 返回string,参数int的委托 简单示例_Core