net 匿名类型 匿名方法


//匿名类型匿名方法
namespace Anonymous_Type
{
    delegate void Speak(string a);
    class Program
    {
        static void Main(string[] args)
        {
            //匿名类型
            var n = new { name = "school", age = 25 };
            Console.WriteLine(n.name);
            Console.WriteLine(n.age);
            //匿名方法
            Speak ss = delegate (string b) { Console.WriteLine("this is the string {0}", b); };
            ss("what do you want?");
            Console.ReadKey();
        }
    }
}



作者:spike

分类: Net

创作时间:2023-06-25

更新时间:2024-12-09

联系方式放在中括号之中例如[[email protected]],回复评论在开头加上标号例如:#1