问一个C#的MVC问题,不知道参数啥意思

2025-04-30 13:55:45
推荐回答(1个)
回答1:

        static void Main(string[] args)
        {
            AddWatch("hello{0}", () =>
                {
                    return " world";
                }
                );
            //输出hello world
            Console.ReadLine();
        }

        //你那个函数定义是否是类似如下
        //下面函数的输出是输出以s为格式化字符串,
        //以函数f的返回值为占位符的值
        static void AddWatch(string s, Func f)
        {
            Console.WriteLine(s, f());
        }