C# dynamic

        [TestMethod]
        public void DynamicTest()
        {
            dynamic Customer = new ExpandoObject();
            Customer.Name = "Lucy";
            Customer.Age = 20;
            Customer.Female = true;

            var obj = new { name="zy", age="20" };

            var t =obj.GetType().ToString();
            var t2 = Customer.GetType().ToString();

            Assert.AreEqual(Customer.Name, "Lucy"); 
            
        }

  On your solution explorer window, right click to References, select Add Reference, go to .NET tab, find and add Microsoft.CSharp.

原文地址:https://www.cnblogs.com/zyip/p/3535197.html