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.

 

你可能感兴趣的:(dynamic)